AlloyDB Omni용 PostGIS 설치

문서 버전을 선택합니다.

AlloyDB Omni에는 PostGIS 확장 프로그램이 포함되어 있지 않지만 이 페이지의 안내에 따라 지리 공간 데이터의 저장, 색인 생성, 쿼리를 지원하도록 기존 AlloyDB Omni 설치에 수동으로 추가할 수 있습니다.

시작하기 전에

시스템에 AlloyDB Omni를 설치했는지 확인합니다.

AlloyDB Omni 설치에 PostGIS 추가

AlloyDB Omni 설치에 PostGIS 확장 프로그램을 추가하려면 다음 단계를 따르세요.

  1. 설치된 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: 15.12.0
    

    AlloyDB Omni 버전 번호를 기록해 둡니다. 다음 단계에서 필요합니다.

  2. OMNI_VERSION 환경 변수를 설정합니다.
    OMNI_VERSION=VERSION

    VERSION을 이전 단계의 전체 데이터베이스 서버 버전으로 바꿉니다(예: 15.12.0).

  3. PostGIS를 포함하는 새 AlloyDB Omni 컨테이너를 만듭니다.

    Linux

           mkdir ~/alloydb-omni-postgis
           tee -a ~/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-15-postgis-3 &&
    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 .

    macOS

           mkdir ~/alloydb-omni-postgis
           tee -a ~/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-15-postgis-3 &&
    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 .
  4. AlloyDB Omni가 포함된 새 컨테이너를 my-omni-postgis라는 이름으로 만듭니다.

    Docker

    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
  5. PostGIS 확장 프로그램으로 데이터베이스에 연결합니다.

    docker exec -it my-omni-postgis psql -h localhost -U postgres
  6. 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)