AlloyDB Omni n'inclut pas l'extension PostGIS, mais vous pouvez l'ajouter manuellement à une installation AlloyDB Omni existante en suivant les instructions de cette page pour prendre en charge le stockage, l'indexation et l'interrogation des données géospatiales.
Avant de commencer
Assurez-vous d'avoir installé AlloyDB Omni sur votre système.
Ajouter PostGIS à votre installation AlloyDB Omni
Pour ajouter l'extension PostGIS à votre installation AlloyDB Omni, procédez comme suit:
- Recherchez les libellés de version AlloyDB Omni installés :
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
Le résultat ressemble à ce qui suit :
AlloyDB Omni version: 15.7.0
Notez le numéro de version d'AlloyDB Omni. Vous en aurez besoin à l'étape suivante.
- Définissez la variable d'environnement
OMNI_VERSION
:OMNI_VERSION=VERSION
Remplacez VERSION par la version complète du serveur de base de données de l'étape précédente (par exemple,
15.7.0
). - Créez un conteneur AlloyDB Omni qui inclut PostGIS:
Linux
mkdir ~/alloydb-omni-postgis
tee -a ~/alloydb-omni-postgis/Dockerfile << EOF ARG OMNI_VERSION FROM google/alloydbomni:${OMNI_VERSION} RUN apt-get update &&
apt-get install -y --no-install-recommends
postgresql-15-postgis-3 &&
apt-get purge -y --auto-remove &&
rm -rf /var/lib/apt/lists/* EOFcd ~/alloydb-omni-postgis
sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-postgis:$OMNI_VERSION .
macOS
mkdir ~/alloydb-omni-postgis
tee -a ~/alloydb-omni-postgis/Dockerfile << EOF ARG OMNI_VERSION FROM google/alloydbomni:${OMNI_VERSION} RUN apt-get update &&
apt-get install -y --no-install-recommends
postgresql-15-postgis-3 &&
apt-get purge -y --auto-remove &&
rm -rf /var/lib/apt/lists/* EOFcd ~/alloydb-omni-postgis
sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-postgis:$OMNI_VERSION .
- Créez un conteneur avec AlloyDB Omni nommé
my-omni-postgis
:Docker
docker run --name my-omni-postgis -e POSTGRES_PASSWORD=NEW_PASSWORD -d google/alloydbomni-with-postgis:OMNI_VERSION
Podman
podman run --name my-omni-postgis -e POSTGRES_PASSWORD=NEW_PASSWORD -d google/alloydbomni-with-postgis:OMNI_VERSION
Connectez-vous à votre base de données avec l'extension PostGIS:
docker exec -it my-omni-postgis psql -h localhost -U postgres
Activez PostGIS:
CREATE EXTENSION IF NOT EXISTS POSTGIS;
SELECT postgis_full_version();
La sortie ressemble à ceci :
postgres=# SELECT postgis_full_version();
postgis_full_version
--------------------------------------------------------------------------------------------------------------------------------
POSTGIS="3.3.2 4975da8" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1" PROJ="9.1.1" LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)"
(1 row)