이 페이지에서는 기존 AlloyDB Omni 설치에 PostGIS 확장 프로그램을 수동으로 추가하는 방법을 설명합니다. PostGIS 확장 프로그램을 사용하면 지리 공간 데이터를 저장, 색인 생성, 쿼리할 수 있습니다.
다음 방법 중 하나를 사용하여 PostGIS를 설치할 수 있습니다.
- Docker 또는 Podman CLI에서 Debian 옵션을 사용합니다. Docker는 데몬을 사용하며 대부분의 작업에 루트 권한이 필요한 반면 Podman은 데몬이 없고 루트 권한이 없습니다.
- 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.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
출력은 다음과 비슷합니다.
AlloyDB Omni version: 16.8.0
다음 단계에서 필요하므로 AlloyDB Omni 버전 번호를 기록해 둡니다.
OMNI_VERSION
환경 변수를 설정합니다.OMNI_VERSION=VERSION
VERSION
을 이전 단계의 전체 데이터베이스 서버 버전(예:16.8.0
)으로 바꿉니다.PostGIS 확장 프로그램을 포함하는 맞춤 Docker 이미지를 빌드합니다.
mkdir ~/alloydb-omni-postgis cd ~/alloydb-omni-postgis sudo dnf install -y subscription-manager sudo subscription-manager register --username EMAIL --password PASSWORD --auto-attach sudo mkdir -p entitlement rhsm-conf rhsm-ca sudo cp -r /etc/pki/entitlement/* entitlement/ sudo cp -r /etc/rhsm/rhsm.conf rhsm-conf/ sudo cp -r /etc/rhsm/ca/* rhsm-ca/ cat <<EOF > Dockerfile FROM google/alloydbomni:16.8.0-ubi COPY ./entitlement /etc/pki/entitlement COPY ./rhsm-conf /etc/rhsm COPY ./rhsm-ca /etc/rhsm/ca RUN arch=$(uname -m) && \ subscription-manager repos --enable codeready-builder-for-rhel-9-${arch}-rpms && \ dnf install -y \ https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-${arch}/pgdg-redhat-repo-latest.noarch.rpm && \ dnf install -y postgresql16-server postgis34_16 && \ dnf clean all # 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. RUN for file in /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." && exit 1); \ else \ echo "$target already exists"; \ fi; \ done && \ for file in /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." && exit 1); \ else \ echo "$target already exists"; \ fi; \ done EOF
AlloyDB Omni가 포함된 새 컨테이너를 만듭니다(이름:
my-omni-postgis
).Docker
docker build -t google/alloydbomni-with-postgis:latest 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
PostGIS 확장 프로그램으로 데이터베이스에 연결합니다.
docker exec -it my-omni-postgis psql -h localhost -U postgres
PostGIS를 사용 설정합니다.
CREATE EXTENSION IF NOT EXISTS POSTGIS; SELECT postgis_full_version();
결과는 다음과 유사합니다.
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)