Cette page explique comment ajouter manuellement l'extension orafce à une installation AlloyDB Omni existante. L'extension orafce fournit des fonctions et des opérateurs qui émulent un sous-ensemble de fonctions et de packages à partir de la base de données Oracle. Cette extension simplifie la migration des applications d'Oracle vers des bases de données compatibles avec PostgreSQL, comme AlloyDB Omni.
Avant de commencer
Installez AlloyDB Omni sur votre système.
Ajouter orafce à votre installation AlloyDB Omni
Pour ajouter l'extension orafce à votre installation AlloyDB Omni, procédez comme suit :
Recherchez les libellés de la version d'AlloyDB Omni que vous avez installée :
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
Le résultat ressemble à ce qui suit :
AlloyDB Omni version: 16.8.0
Notez le numéro de version d'AlloyDB Omni, car vous en aurez besoin à l'étape suivante.
Créez une image Docker personnalisée incluant l'extension orafce :
$ ~/alloydb-omni-orafce $ cd ~/alloydb-omni-orafce $ cat <<EOF > Dockerfile FROM google/alloydbomni:16.8.0-ubi RUN arch=$(uname -m) RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-$(arch)/pgdg-redhat-repo-latest.noarch.rpm RUN dnf install -y orafce_16 # On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib. # This step creates symbolic links to those files in the paths expected by AlloyDB Omni, # which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data. RUN \ for file in /usr/pgsql-16/share/extension/*; do \ target="/usr/lib/postgresql/16/share/extension/$(realpath -m --relative-to=/usr/pgsql-16/share/extension/ "$file")"; \ if [ ! -e "$target" ]; then \ ln -s "$file" "$target" || (echo "Failed to link \"$file\" to \"$target\", exiting." && exit 1); \ else \ echo "$target already exists"; \ fi; \ done && \ for file in /usr/pgsql-16/lib/*; do \ target="/usr/lib/postgresql/16/lib/$(realpath -m --relative-to=/usr/pgsql-16/lib/ "$file")"; \ if [ ! -e "$target" ]; then \ ln -s "$file" "$target" || (echo "Failed to link \"$file\" to \"$target\", exiting." && exit 1); \ else \ echo "$target already exists"; \ fi; \ done EOF
Créez un conteneur avec AlloyDB Omni nommé
my-omni-orafce
:docker build -t google/alloydbomni-with-orafce:latest 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é :
SELECT oracle.sysdate();
Le résultat ressemble à ce qui suit :
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)