Installa Orafce per AlloyDB Omni

Seleziona una versione della documentazione:

AlloyDB Omni non include l'estensione Orafce, ma puoi aggiungerla manualmente a un'installazione AlloyDB Omni esistente seguendo le istruzioni riportate in questa pagina per fornire funzioni e operatori aggiuntivi dal database Oracle.

Prima di iniziare

Assicurati di aver installato AlloyDB Omni sul tuo sistema.

Server singolo

Aggiungere Orafce all'installazione di AlloyDB Omni

Per aggiungere l'estensione Orafce all'installazione di AlloyDB Omni:

  1. Trova le etichette della versione di AlloyDB Omni installata:
    docker run --rm -it  google/alloydbomni cat VERSION.txt

    L'output è simile al seguente:

    AlloyDB Omni version: 15.5.4
    

    Prendi nota del numero di versione di AlloyDB Omni, che ti servirà nel passaggio successivo.

  2. Imposta la variabile di ambiente OMNI_VERSION:
    OMNI_VERSION=VERSION

    Sostituisci VERSION con la versione completa del server di database del passaggio precedente, ad esempio 15.5.4.

  3. Crea un nuovo container AlloyDB Omni che includa Orafce:

    Docker

      mkdir ~/alloydb-omni-orafce
      tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
      ARG OMNI_VERSION
    
      FROM postgres:15-bookworm AS postgres
    
      RUN apt-get update && \
      apt-get install -y --no-install-recommends \
      postgresql-15-orafce && \
      apt-get purge -y --auto-remove && \
      rm -rf /var/lib/apt/lists/*
    
      FROM google/alloydbomni:${OMNI_VERSION}
    
      COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so
      COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/
    
      COPY --from=postgres /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
      COPY --from=postgres /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
      EOF
      cd ~/alloydb-omni-orafce
      sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
      

    Podman

      mkdir ~/alloydb-omni-orafce
      tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
      ARG OMNI_VERSION
    
      FROM postgres:15-bookworm AS postgres
    
      RUN apt-get update && \
      apt-get install -y --no-install-recommends \
      postgresql-15-orafce && \
      apt-get purge -y --auto-remove && \
      rm -rf /var/lib/apt/lists/*
    
      FROM google/alloydbomni:${OMNI_VERSION}
    
      COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so
      COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/
    
      COPY --from=postgres /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
      COPY --from=postgres /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
      EOF
      cd ~/alloydb-omni-orafce
      sudo podman build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
      

    Docker

      mkdir ~/alloydb-omni-orafce
      tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
      ARG OMNI_VERSION
    
      FROM postgres:15-bookworm AS postgres
    
      RUN apt-get update && \
      apt-get install -y --no-install-recommends \
      postgresql-15-orafce && \
      apt-get purge -y --auto-remove && \
      rm -rf /var/lib/apt/lists/*
    
      FROM google/alloydbomni:${OMNI_VERSION}
    
      COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so
      COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/
    
      COPY --from=postgres /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
      COPY --from=postgres /lib/aarch64-linux-gnu/ /lib/aarch64-linux-gnu/
      EOF
      cd ~/alloydb-omni-orafce
      sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
      

    Podman

      mkdir ~/alloydb-omni-orafce
      tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
      ARG OMNI_VERSION
    
      FROM postgres:15-bookworm AS postgres
    
      RUN apt-get update && \
      apt-get install -y --no-install-recommends \
      postgresql-15-orafce && \
      apt-get purge -y --auto-remove && \
      rm -rf /var/lib/apt/lists/*
    
      FROM google/alloydbomni:${OMNI_VERSION}
    
      COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so
      COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/
    
      COPY --from=postgres /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
      COPY --from=postgres /lib/aarch64-linux-gnu/ /lib/aarch64-linux-gnu/
      EOF
      cd ~/alloydb-omni-orafce
      sudo podman build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
  4. Crea un nuovo container con AlloyDB Omni denominato my-omni-orafce:

    Docker

    docker run --name my-omni-orafce  -e POSTGRES_PASSWORD=NEW_PASSWORD  -d google/alloydbomni-with-orafce:OMNI_VERSION

    Podman

    podman run --name my-omni-orafce  -e POSTGRES_PASSWORD=NEW_PASSWORD  -d google/alloydbomni-with-orafce:OMNI_VERSION
  5. Connettiti al database con l'estensione Orafce:

    Docker

    docker exec -it my-omni-orafce psql -h localhost -U postgres

    Podman

    podman exec -it my-omni-orafce psql -h localhost -U postgres
  6. Attiva Orafce:
    CREATE EXTENSION IF NOT EXISTS ORAFCE;
  7. Verifica che Orafce sia installato e attivo:
    SELECT oracle.sysdate();
    L'output è simile al seguente:
    postgres=# SELECT oracle.sysdate();
         sysdate
    ---------------------
    2024-06-10 16:36:30
    (1 row)