Hinweise
Prüfen Sie, ob Sie AlloyDB Omni auf Ihrem System installiert haben.
PostGIS zur AlloyDB Omni-Installation hinzufügen
So fügen Sie Ihrer AlloyDB Omni-Installation die PostGIS-Erweiterung hinzu:
- So finden Sie die Labels Ihrer installierten AlloyDB Omni-Version:
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
Die Ausgabe sieht etwa so aus:
AlloyDB Omni version: 15.7.1
Notieren Sie sich die AlloyDB Omni-Versionsnummer. Sie benötigen sie im nächsten Schritt.
- Legen Sie die Umgebungsvariable
OMNI_VERSION
fest:OMNI_VERSION=VERSION
Ersetzen Sie VERSION durch die vollständige Datenbankserverversion aus dem vorherigen Schritt, z. B.
15.7.1
. - Erstellen Sie einen neuen AlloyDB Omni-Container, der PostGIS enthält:
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 .
- Erstellen Sie einen neuen Container mit AlloyDB Omni mit dem Namen
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
Stellen Sie eine Verbindung zu Ihrer Datenbank mit der PostGIS-Erweiterung her:
docker exec -it my-omni-postgis psql -h localhost -U postgres
PostGIS aktivieren:
CREATE EXTENSION IF NOT EXISTS POSTGIS;
SELECT postgis_full_version();
Die Ausgabe sieht dann ungefähr so aus:
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)