Install Orafce for AlloyDB Omni

AlloyDB Omni does not include the Orafce extension, but you can manually add it to an existing AlloyDB Omni installation by following the instructions on this page.

Before you begin

Ensure that you meet the following system requirements:

Add Orafce to your AlloyDB Omni installation

To add the Orafce extension to your AlloyDB Omni installation, follow these steps:

  1. Find your installed AlloyDB Omni version labels:
    sudo alloydb version

    The output is similar to the following:

    AlloyDB Omni CLI version: 1.0
    AlloyDB Omni database server version: 15.2.0
    

    Take note of the database server version number; you need it in the next step.

  2. Set the OMNI_VERSION environment variable:
    OMNI_VERSION=VERSION

    Replace VERSION with the complete database server version from the previous step—for example, 15.2.0.

  3. Create a new AlloyDB Omni container that includes Orafce:
    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 gcr.io/alloydb-omni/pg-service:${OMNI_VERSION}
    
    COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /lib/orafce.so
    COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /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 gcr.io/alloydb-omni/pg-service-with-orafce:$OMNI_VERSION .
  4. Stop the database server:
    sudo alloydb database-server stop
    
  5. Open /var/alloydb/config/dataplane.conf in a text editor.
  6. Modify the line that defines the PG_IMAGE variable so that it refers to the container that you built in a previous step:
    PG_IMAGE=gcr.io/alloydb-omni/pg-service-with-orafce
    
  7. Start AlloyDB Omni:
    sudo alloydb database-server start
    
  8. Connect to your database:
    sudo docker exec -it pg-service psql -h localhost -U postgres
    
  9. Enable Orafce:
    CREATE EXTENSION IF NOT EXISTS ORAFCE;
  10. Confirm that Orafce is installed and enabled:
    SELECT oracle.sysdate();