AlloyDB Omni n'inclut pas l'extension Orafce, mais vous pouvez l'ajouter manuellement à une installation AlloyDB Omni existante en suivant les instructions de cette page pour fournir des fonctions et des opérateurs supplémentaires à partir de la base de données Oracle.
Avant de commencer
Assurez-vous d'avoir installé AlloyDB Omni sur votre système.
Serveur unique
Ajouter Orafce à votre installation AlloyDB Omni
Pour ajouter l'extension Orafce à votre installation AlloyDB Omni, procédez comme suit:
- Recherchez les libellés de version AlloyDB Omni installés:
docker run --rm -it google/alloydbomni cat VERSION.txt
Le résultat ressemble à ce qui suit :
AlloyDB Omni version: 15.5.3
Notez le numéro de version d'AlloyDB Omni. Vous en aurez besoin à l'étape suivante.
- Définissez la variable d'environnement
OMNI_VERSION
:OMNI_VERSION=VERSION
Remplacez VERSION par la version complète du serveur de base de données de l'étape précédente (par exemple,
15.5.3
). - Créez un conteneur AlloyDB Omni qui inclut Orafce :
Linux
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 .
macOS
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 .
- Créez un conteneur avec AlloyDB Omni nommé
my-omni-orafce
:docker run --name my-omni-orafce -e POSTGRES_PASSWORD=NEW_PASSWORD -d google/alloydbomni-with-orafce:OMNI_VERSION
- Connectez-vous à votre base de données avec l'extension Orafce:
docker exec -it my-omni-orafce psql -h localhost -U postgres
- Activez Orafce:
CREATE EXTENSION IF NOT EXISTS ORAFCE;
- Vérifiez qu'Orafce est installé et activé:
La sortie ressemble à ceci:SELECT oracle.sysdate();
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)