Auf dieser Seite wird beschrieben, wie Sie einer vorhandenen AlloyDB Omni-Installation manuell die PostGIS-Erweiterung hinzufügen. Mit der PostGIS-Erweiterung können Geodaten gespeichert, indexiert und abgefragt werden.
Sie können PostGIS mit einer der folgenden Methoden installieren:
Verwenden Sie Debian-Optionen in der Docker- oder Podman-Befehlszeile. Docker basiert auf einem Daemon und erfordert für die meisten Vorgänge Root-Rechte, während Podman ohne Daemon und ohne Root-Rechte auskommt.
Verwenden Sie Red Hat Universal Base Images (UBI). UBI-Container-Basisbetriebssystem-Images werden aus Teilen von Red Hat Enterprise Linux (RHEL) erstellt.
So fügen Sie die PostGIS-Erweiterung Ihrer AlloyDB Omni-Installation hinzu:
So finden Sie die Labels der installierten AlloyDB Omni-Version:
Docker
dockerrun--rm-itgoogle/alloydbomnicatVERSION.txt
Podman
podmanrun--rm-itgoogle/alloydbomnicatVERSION.txt
Die Ausgabe sieht etwa so aus:
AlloyDB Omni version: 16.8.0
Notieren Sie sich die AlloyDB Omni-Versionsnummer, da Sie sie im nächsten Schritt benötigen.
Legen Sie die Umgebungsvariable OMNI_VERSION fest:
OMNI_VERSION=VERSION
Ersetzen Sie VERSION durch die vollständige Datenbankserverversion aus dem vorherigen Schritt, z. B. 16.8.0.
Erstellen Sie ein benutzerdefiniertes Docker-Image, das die PostGIS-Erweiterung enthält:
mkdir~/alloydb-omni-postgis
cd~/alloydb-omni-postgis
sudodnfinstall-ysubscription-manager
sudosubscription-managerregister--usernameEMAIL--passwordPASSWORD--auto-attach
sudomkdir-pentitlementrhsm-confrhsm-ca
sudocp-r/etc/pki/entitlement/*entitlement/
sudocp-r/etc/rhsm/rhsm.confrhsm-conf/
sudocp-r/etc/rhsm/ca/*rhsm-ca/
cat<<EOF > Dockerfile
FROMgoogle/alloydbomni:16.8.0-ubi
COPY./entitlement/etc/pki/entitlement
COPY./rhsm-conf/etc/rhsm
COPY./rhsm-ca/etc/rhsm/ca
RUNarch=$(uname-m) && \subscription-managerrepos--enablecodeready-builder-for-rhel-9-${arch}-rpms && \dnfinstall-y\https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-${arch}/pgdg-redhat-repo-latest.noarch.rpm && \dnfinstall-ypostgresql16-serverpostgis34_16 && \dnfcleanall
# On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib.# This step creates symbolic links to those files in the paths expected by AlloyDB Omni,# which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data.RUNforfilein/usr/pgsql-16/share/extension/*;do\target="/usr/lib/postgresql/16/share/extension/$(realpath-m--relative-to=/usr/pgsql-16/share/extension/"$file")";\if[!-e"$target"];then\ln-s"$file""$target"||(echo"Failed to link \"$file\" to \"$target\", exiting." && exit1);\else\echo"$target already exists";\fi;\done && \forfilein/usr/pgsql-16/lib/*;do\target="/usr/lib/postgresql/16/lib/$(realpath-m--relative-to=/usr/pgsql-16/lib/"$file")";\if[!-e"$target"];then\ln-s"$file""$target"||(echo"Failed to link \"$file\" to \"$target\", exiting." && exit1);\else\echo"$target already exists";\fi;\done
EOF
Erstellen Sie einen neuen Container mit AlloyDB Omni mit dem Namen my-omni-postgis:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[],[],null,["# Install PostGIS for AlloyDB Omni\n\nSelect a documentation version: 16.8.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/install-postgis)\n- [16.8.0](/alloydb/omni/16.8.0/docs/install-postgis)\n- [16.3.0](/alloydb/omni/16.3.0/docs/install-postgis)\n- [15.12.0](/alloydb/omni/15.12.0/docs/install-postgis)\n- [15.7.1](/alloydb/omni/15.7.1/docs/install-postgis)\n- [15.7.0](/alloydb/omni/15.7.0/docs/install-postgis)\n- [15.5.5](/alloydb/omni/15.5.5/docs/install-postgis)\n- [15.5.4](/alloydb/omni/15.5.4/docs/install-postgis)\n- [15.5.2](/alloydb/omni/15.5.2/docs/install-postgis)\n\n\u003cbr /\u003e\n\nDebian UBI\n\n\u003cbr /\u003e\n\nThis page describes how to manually add the [PostGIS\nextension](http://www.postgis.net/) to an existing AlloyDB Omni\ninstallation. The PostGIS extension enables storing, indexing, and querying\ngeospatial data.\n\nYou can install PostGIS using either of the following methods:\n\n- Use Debian options in the Docker or Podman CLI. Docker relies on a daemon and requires root privileges for most operations, while Podman is daemonless and rootless.\n- Use Red Hat Universal Base Images (UBI). UBI container base operating system images are built from parts of Red Hat Enterprise Linux (RHEL).\n\nBefore you begin\n----------------\n\n[Install AlloyDB Omni](/alloydb/omni/16.8.0/docs/install) on your system.\n\nAdd PostGIS to your AlloyDB Omni installation\n---------------------------------------------\n\nTo add the PostGIS extension to your AlloyDB Omni installation,\nfollow these steps:\n\n1. Find your installed AlloyDB Omni version labels:\n\n ### Docker\n\n docker run --rm -it google/alloydbomni cat VERSION.txt\n\n ### Podman\n\n podman run --rm -it google/alloydbomni cat VERSION.txt\n\n The output is similar to the following: \n\n AlloyDB Omni version: 16.8.0\n\n Take note of the AlloyDB Omni version number because you need it in the next step.\n2. Set the \u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e environment variable:\n\n OMNI_VERSION=\u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e with the complete database server version from the previous step, for example, `16.8.0`.\n3. Build a custom Docker image that includes the PostGIS extension:\n\n mkdir ~/alloydb-omni-postgis\n\n cd ~/alloydb-omni-postgis\n\n sudo dnf install -y subscription-manager\n\n sudo subscription-manager register --username \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e --password \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e --auto-attach\n\n sudo mkdir -p entitlement rhsm-conf rhsm-ca\n sudo cp -r /etc/pki/entitlement/* entitlement/\n sudo cp -r /etc/rhsm/rhsm.conf rhsm-conf/\n sudo cp -r /etc/rhsm/ca/* rhsm-ca/\n\n cat \u003c\u003cEOF \u003e Dockerfile\n FROM google/alloydbomni:16.8.0-ubi\n COPY ./entitlement /etc/pki/entitlement\n COPY ./rhsm-conf /etc/rhsm\n COPY ./rhsm-ca /etc/rhsm/ca\n RUN arch=$(uname -m) && \\\n subscription-manager repos --enable codeready-builder-for-rhel-9-${arch}-rpms && \\\n dnf install -y \\\n https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-${arch}/pgdg-redhat-repo-latest.noarch.rpm && \\\n dnf install -y postgresql16-server postgis34_16 && \\\n dnf clean all\n # On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib.\n # This step creates symbolic links to those files in the paths expected by AlloyDB Omni,\n # which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data.\n RUN for file in /usr/pgsql-16/share/extension/*; do \\\n target=\"/usr/lib/postgresql/16/share/extension/$(realpath -m --relative-to=/usr/pgsql-16/share/extension/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done && \\\n for file in /usr/pgsql-16/lib/*; do \\\n target=\"/usr/lib/postgresql/16/lib/$(realpath -m --relative-to=/usr/pgsql-16/lib/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done\n EOF\n\n \u003cbr /\u003e\n\n4. Create a new container with AlloyDB Omni named `my-omni-postgis`:\n\n ### Docker\n\n docker build -t google/alloydbomni-with-postgis:latest\n docker run --name my-omni-postgis -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003eNEW_PASSWORD\u003c/var\u003e -d google/alloydbomni-with-postgis:\u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e\n\n ### Podman\n\n podman run --name my-omni-postgis -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003eNEW_PASSWORD\u003c/var\u003e -d google/alloydbomni-with-postgis:\u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e\n\n5. Connect to your database with the PostGIS extension:\n\n docker exec -it my-omni-postgis psql -h localhost -U postgres\n\n6. Enable PostGIS:\n\n CREATE EXTENSION IF NOT EXISTS POSTGIS;\n SELECT postgis_full_version();\n\n The output looks similar to the following: \n\n postgres=# SELECT postgis_full_version();\n postgis_full_version\n --------------------------------------------------------------------------------------------------------------------------------\n 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)\"\n (1 row)"]]