Instalar Orafce para AlloyDB Omni

Selecciona una versión de la documentación:

AlloyDB Omni no incluye la extensión Orafce, pero puedes añadirla manualmente a una instalación de AlloyDB Omni siguiendo las instrucciones de esta página para proporcionar funciones y operadores adicionales de la base de datos Oracle.

Antes de empezar

Asegúrate de haber instalado AlloyDB Omni en tu sistema.

Un solo servidor

Añadir Orafce a tu instalación de AlloyDB Omni

Para añadir la extensión Orafce a tu instalación de AlloyDB Omni, sigue estos pasos:

  1. Para encontrar las etiquetas de la versión de AlloyDB Omni que tienes instalada, sigue estos pasos:

    Docker

    docker run --rm -it  google/alloydbomni cat VERSION.txt

    Podman

    podman run --rm -it  google/alloydbomni cat VERSION.txt

    El resultado debería ser similar al siguiente:

    AlloyDB Omni version: 15.5.5
    

    Anota el número de versión de AlloyDB Omni, ya que lo necesitarás en el siguiente paso.

  2. Define la variable de entorno OMNI_VERSION:
    OMNI_VERSION=VERSION

    Sustituye VERSION por la versión completa del servidor de la base de datos del paso anterior; por ejemplo, 15.5.5.

  3. Crea un contenedor de AlloyDB Omni que incluya 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 contenedor con AlloyDB Omni llamado 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. Conéctate a tu base de datos con la extensión 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. Habilita Orafce:
    CREATE EXTENSION IF NOT EXISTS ORAFCE;
  7. Confirma que Orafce está instalado y habilitado:
    SELECT oracle.sysdate();
    La salida es similar a la siguiente:
    postgres=# SELECT oracle.sysdate();
         sysdate
    ---------------------
    2024-06-10 16:36:30
    (1 row)