Auf dieser Seite wird beschrieben, wie Sie einer vorhandenen AlloyDB Omni-Installation manuell die orafce-Erweiterung hinzufügen. Die orafce-Erweiterung bietet Funktionen und Operatoren, die einen Teil der Funktionen und Pakete aus der Oracle-Datenbank emulieren. Diese Erweiterung vereinfacht die Migration von Anwendungen von Oracle zu PostgreSQL-kompatiblen Datenbanken wie AlloyDB Omni.
orafce zu Ihrer AlloyDB Omni-Installation hinzufügen
So fügen Sie Ihrer AlloyDB Omni-Installation die orafce-Erweiterung hinzu:
So finden Sie die Labels der installierten AlloyDB Omni-Version:
Docker
dockerrun--rm-itgoogle/alloydbomnicatVERSION.txt
Podman
podmanrun--rm-itgoogle/alloydbomnicatVERSION.txt
Die Ausgabe sieht etwa so aus:
AlloyDB Omni version: 16.8.0
Notieren Sie sich die AlloyDB Omni-Versionsnummer, da Sie sie im nächsten Schritt benötigen.
Erstellen Sie ein benutzerdefiniertes Docker-Image, das die orafce-Erweiterung enthält:
$~/alloydb-omni-orafce
$cd~/alloydb-omni-orafce
$cat<<EOF > Dockerfile
FROMgoogle/alloydbomni:16.8.0-ubi
RUNarch=$(uname-m)
RUNdnfinstall-yhttps://download.postgresql.org/pub/repos/yum/reporpms/EL-9-$(arch)/pgdg-redhat-repo-latest.noarch.rpm
RUNdnfinstall-yorafce_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\forfilein/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." && exit1);\else\echo"$target already exists";\fi;\done && \forfilein/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." && exit1);\else\echo"$target already exists";\fi;\done
EOF
Erstellen Sie einen neuen Container mit AlloyDB Omni mit dem Namen my-omni-orafce:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-02 (UTC)."],[],[],null,["# Install orafce for AlloyDB Omni\n\nSelect a documentation version: 16.8.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/install-orafce)\n- [16.8.0](/alloydb/omni/16.8.0/docs/install-orafce)\n- [16.3.0](/alloydb/omni/16.3.0/docs/install-orafce)\n- [15.12.0](/alloydb/omni/15.12.0/docs/install-orafce)\n- [15.7.1](/alloydb/omni/15.7.1/docs/install-orafce)\n- [15.7.0](/alloydb/omni/15.7.0/docs/install-orafce)\n- [15.5.5](/alloydb/omni/15.5.5/docs/install-orafce)\n- [15.5.4](/alloydb/omni/15.5.4/docs/install-orafce)\n- [15.5.2](/alloydb/omni/15.5.2/docs/install-orafce)\n\n\u003cbr /\u003e\n\nDebian UBI\n\n\u003cbr /\u003e\n\nThis page describes how to manually add the [orafce extension](https://github.com/orafce/orafce)\nto an existing AlloyDB Omni installation. The orafce extension\nprovides functions and operators that emulate a subset of functions and packages\nfrom the Oracle database. This extension simplifies migration of applications from\nOracle to PostgreSQL-compatible databases such as AlloyDB Omni.\n\nBefore you begin\n----------------\n\n[Install AlloyDB Omni](/alloydb/omni/16.8.0/docs/install) on your system.\n\nAdd orafce to your AlloyDB Omni installation\n--------------------------------------------\n\nTo add the orafce extension to your AlloyDB Omni installation,\nfollow these steps:\n\n1. Find your installed AlloyDB Omni version labels:\n\n ### Docker\n\n docker run --rm -it google/alloydbomni cat VERSION.txt\n\n ### Podman\n\n podman run --rm -it google/alloydbomni cat VERSION.txt\n\n The output is similar to the following: \n\n AlloyDB Omni version: 16.8.0\n\n Take note of the AlloyDB Omni version number because you need it in the next step.\n2. Build a custom Docker image that includes the orafce extension:\n\n $ ~/alloydb-omni-orafce\n\n $ cd ~/alloydb-omni-orafce\n\n $ cat \u003c\u003cEOF \u003e Dockerfile\n FROM google/alloydbomni:16.8.0-ubi\n RUN arch=$(uname -m)\n RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-$(arch)/pgdg-redhat-repo-latest.noarch.rpm\n RUN dnf install -y orafce_16\n\n # On RHEL-based systems, PostgreSQL extensions like Orafce and PostGIS are typically installed in /usr/pgsql-16/share/extension and /usr/pgsql-16/lib.\n # This step creates symbolic links to those files in the paths expected by AlloyDB Omni,\n # which lets AlloyDB Omni locate extension control files and shared libraries without duplicating data.\n RUN \\\n for file in /usr/pgsql-16/share/extension/*; do \\\n target=\"/usr/lib/postgresql/16/share/extension/$(realpath -m --relative-to=/usr/pgsql-16/share/extension/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done && \\\n for file in /usr/pgsql-16/lib/*; do \\\n target=\"/usr/lib/postgresql/16/lib/$(realpath -m --relative-to=/usr/pgsql-16/lib/ \"$file\")\"; \\\n if [ ! -e \"$target\" ]; then \\\n ln -s \"$file\" \"$target\" || (echo \"Failed to link \\\"$file\\\" to \\\"$target\\\", exiting.\" && exit 1); \\\n else \\\n echo \"$target already exists\"; \\\n fi; \\\n done\n EOF\n\n\n3. Create a new container with AlloyDB Omni named `my-omni-orafce`:\n\n docker build -t google/alloydbomni-with-orafce:latest\n docker run --name my-omni-orafce -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003eNEW_PASSWORD\u003c/var\u003e -d google/alloydbomni-with-orafce:\u003cvar translate=\"no\"\u003eOMNI_VERSION\u003c/var\u003e\n\n4. Connect to your database with the orafce extension:\n\n docker exec -it my-omni-orafce psql -h localhost -U postgres\n\n5. Enable orafce:\n\n CREATE EXTENSION IF NOT EXISTS ORAFCE;\n\n6. Confirm that orafce is installed and enabled:\n\n SELECT oracle.sysdate();\n\n The output is similar to the following: \n\n postgres=# SELECT oracle.sysdate();\n sysdate\n ---------------------\n 2024-06-10 16:36:30\n (1 row)\n\n | **Note:** Due to some known issues with the orafce extension on AlloyDB Omni, we don't recommend that you use the `dbms_utility.format_call_stack`, `dbms_output.get_line`, and `regexp_*` functions."]]