Halaman ini menjelaskan cara menambahkan ekstensi PostGIS
secara manual ke penginstalan AlloyDB Omni
yang ada. Ekstensi PostGIS memungkinkan penyimpanan, pengindeksan, dan pembuatan kueri data geospasial.
Anda dapat menginstal PostGIS menggunakan salah satu metode berikut:
Gunakan opsi Debian di Docker atau Podman CLI. Docker mengandalkan daemon
dan memerlukan hak istimewa root untuk sebagian besar operasi, sedangkan Podman tidak memiliki daemon
dan tidak memerlukan root.
Gunakan Red Hat Universal Base Images (UBI). Image sistem operasi dasar container UBI dibangun dari bagian-bagian Red Hat Enterprise Linux (RHEL).
Untuk menambahkan ekstensi PostGIS ke penginstalan AlloyDB Omni Anda,
ikuti langkah-langkah berikut:
Temukan label versi AlloyDB Omni yang terinstal:
Docker
dockerrun--rm-itgoogle/alloydbomnicatVERSION.txt
Podman
podmanrun--rm-itgoogle/alloydbomnicatVERSION.txt
Outputnya mirip dengan hal berikut ini:
AlloyDB Omni version: 16.8.0
Catat nomor versi AlloyDB Omni karena Anda akan membutuhkannya pada langkah berikutnya.
Tetapkan variabel lingkungan OMNI_VERSION:
OMNI_VERSION=VERSION
Ganti VERSION dengan versi server database lengkap dari langkah sebelumnya, misalnya, 16.8.0.
Buat image Docker kustom yang menyertakan ekstensi PostGIS:
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
Buat penampung baru dengan AlloyDB Omni bernama my-omni-postgis:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)"]]