To store, index, and query geospatial data in AlloyDB Omni, you can manually add the PostGIS extension to your installation.
Before you begin
Install AlloyDB Omni on your system.
Add PostGIS to your AlloyDB Omni installation
To add the PostGIS extension to your AlloyDB Omni installation, follow these steps:Initialize Red Hat Subscription Manager on the VM where you installed the AlloyDB Omni server:
sudo dnf install -y subscription-manager sudo subscription-manager register --username "RHSM_USER" --password "RHSM_PASS" --auto-attach --forceReplace the following:
RHSM_USER: the Red Hat Subscription Manager user.RHSM_PASS: the Red Hat Subscription Manager password.
Enable the CodeReady Builder repository:
sudo subscription-manager repos --enable="codeready-builder-for-rhel-9-$ARCH-rpms"Replace
ARCHwith the RHEL architecture that you want to use—for example,x86_64.Add the PostgreSQL Yum repository:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpmInstall the PostGIS extension:
sudo dnf install -y postgis35_18Create required symlinks so the extensions are in the expected paths:
set -e PGVER="18" sudo mkdir -p "/usr/lib/postgresql/${PGVER}/share/extension" for file in /usr/pgsql-${PGVER}/share/extension/*; do target="/usr/lib/postgresql/${PGVER}/share/extension/$(basename "$file")" if [[ ! -e "$target" ]]; then sudo ln -s "$file" "$target" || (echo "Failed to link \"$file\" to \"$target\", exiting." && exit 1) echo "Created extension link for $(basename "$file")" else echo "Target $target already exists." fi done sudo mkdir -p "/usr/lib/postgresql/${PGVER}/lib" for file in /usr/pgsql-${PGVER}/lib/*; do target="/usr/lib/postgresql/${PGVER}/lib/$(basename "$file")" if [[ ! -e "$target" ]]; then sudo ln -s "$file" "$target" || (echo "Failed to link \"$file\" to \"$target\", exiting." && exit 1) echo "Created lib link for $(basename "$file")" else echo "Target $target already exists." fi doneConnect to your database and run the
CREATE EXTENSIONcommand to enable PostGIS:For instructions on connecting to your instance, see Run and connect to AlloyDB Omni.
CREATE EXTENSION IF NOT EXISTS POSTGIS;Confirm that PostGIS is installed and enabled:
SELECT postgis_full_version();The output is similar to the following:
postgres=# SELECT postgis_full_version(); postgis_full_version -------------------------------------------------------------------------------------------------------------------------------- POSTGIS="3.3.2 4975da8" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.18.1" PROJ="9.1.1" LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" (1 row)