Questa pagina descrive come aggiungere manualmente l'estensione orafce a un'installazione esistente di AlloyDB Omni. L'estensione orafce fornisce funzioni e operatori che emulano un sottoinsieme di funzioni e pacchetti del database Oracle. Questa estensione semplifica la migrazione delle applicazioni da Oracle a database compatibili con PostgreSQL come AlloyDB Omni.
Prima di iniziare
Installa AlloyDB Omni sul tuo sistema.
Aggiungi orafce all'installazione di AlloyDB Omni
Per aggiungere l'estensione orafce all'installazione di AlloyDB Omni, segui questi passaggi:
Trova le etichette della versione di AlloyDB Omni installata:
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
L'output è simile al seguente:
AlloyDB Omni version: 16.3.0
Prendi nota del numero di versione di AlloyDB Omni perché ti servirà nel passaggio successivo.
Crea un'immagine Docker personalizzata che includa l'estensione orafce:
$ ~/alloydb-omni-orafce $ cd ~/alloydb-omni-orafce $ cat <<EOF > Dockerfile FROM google/alloydbomni:16.3.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
Crea un nuovo container con AlloyDB Omni denominato
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
Connettiti al tuo database con l'estensione orafce:
docker exec -it my-omni-orafce psql -h localhost -U postgres
Attiva orafce:
CREATE EXTENSION IF NOT EXISTS ORAFCE;
Verifica che orafce sia installato e abilitato:
SELECT oracle.sysdate();
L'output è simile al seguente:
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)