Esta página descreve como adicionar manualmente a extensão orafce a uma instalação existente do AlloyDB Omni. A extensão orafce oferece funções e operadores que emulam um subconjunto de funções e pacotes da base de dados Oracle. Esta extensão simplifica a migração de aplicações do Oracle para bases de dados compatíveis com o PostgreSQL, como o AlloyDB Omni.
Antes de começar
Instale o AlloyDB Omni no seu sistema.
Adicione o orafce à sua instalação do AlloyDB Omni
Para adicionar a extensão orafce à sua instalação do AlloyDB Omni, siga estes passos:
Encontre as etiquetas da versão do AlloyDB Omni instalada:
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
O resultado é semelhante ao seguinte:
AlloyDB Omni version: 16.8.0
Tome nota do número da versão do AlloyDB Omni, pois vai precisar dele no passo seguinte.
Crie uma imagem Docker personalizada que inclua a extensão 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
Crie um novo contentor com o AlloyDB Omni denominado
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
Associe à sua base de dados com a extensão orafce:
docker exec -it my-omni-orafce psql -h localhost -U postgres
Ative o orafce:
CREATE EXTENSION IF NOT EXISTS ORAFCE;
Confirme se o orafce está instalado e ativado:
SELECT oracle.sysdate();
O resultado é semelhante ao seguinte:
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)