AlloyDB Omni で地理空間データを保存、インデックス登録、クエリするには、PostGIS 拡張機能をインストールに手動で追加します。
PostGIS は、次のいずれかの方法でインストールできます。
- Docker または Podman CLI で Debian オプションを使用する。Docker はデーモンに依存しており、ほとんどのオペレーションに root 権限が必要です。一方、Podman はデーモン不要で root 権限なしで動作します。
- Red Hat Universal Base Images(UBI)を使用する。UBI コンテナ ベースのオペレーティング システム イメージは、Red Hat Enterprise Linux(RHEL)の一部からビルドされています。
始める前に
システムに AlloyDB Omni をインストールします。
AlloyDB Omni に PostGIS を追加する
AlloyDB Omni に PostGIS 拡張機能を追加する手順は次のとおりです。インストールされている AlloyDB Omni バージョンのラベルを確認します。
Docker
docker run --rm -it google/alloydbomni cat VERSION.txtPodman
podman run --rm -it google/alloydbomni cat VERSION.txt出力は次のようになります。
AlloyDB Omni version: 18.1.0AlloyDB Omni のバージョン番号をメモします。これは次のステップで必要になります。
OMNI_VERSION環境変数を設定します。OMNI_VERSION=VERSIONVERSIONは、AlloyDB Omni データベース サーバーの完全なバージョンに置き換えます(例:18.1.0)。PostGIS 拡張機能を含むカスタム Docker イメージをビルドします。
mkdir -p ~/alloydb-omni-postgis tee ~/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-18-postgis-3 \ postgresql-18-address-standardizer \ postgresql-18-postgis-tiger-geocoder && \ apt-get purge -y --auto-remove && \ rm -rf /var/lib/apt/lists/* EOF cd ~/alloydb-omni-postgis sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION \ --tag google/alloydbomni-with-postgis:$OMNI_VERSION .AlloyDB Omni を含む
my-omni-postgisという名前のコンテナを作成します。Docker
docker run --name my-omni-postgis \ -e POSTGRES_PASSWORD=NEW_PASSWORD \ -d google/alloydbomni-with-postgis:$OMNI_VERSIONPodman
podman run --name my-omni-postgis \ -e POSTGRES_PASSWORD=NEW_PASSWORD \ -d google/alloydbomni-with-postgis:$OMNI_VERSIONNEW_PASSWORDは、デフォルトのpostgresユーザーのパスワードに置き換えます。PostGIS 拡張機能を使用してデータベースに接続します。
docker exec -it my-omni-postgis psql -h localhost -U postgresPostGIS を有効にします。
CREATE EXTENSION IF NOT EXISTS POSTGIS; 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)