Halaman ini menjelaskan cara menambahkan ekstensi orafce secara manual ke penginstalan AlloyDB Omni yang ada. Ekstensi orafce menyediakan fungsi dan operator yang mengemulasikan subset fungsi dan paket dari database Oracle. Ekstensi ini menyederhanakan migrasi aplikasi dari
Oracle ke database yang kompatibel dengan PostgreSQL seperti AlloyDB Omni.
Menambahkan orafce ke penginstalan AlloyDB Omni Anda
Untuk menambahkan ekstensi orafce ke penginstalan AlloyDB Omni Anda,
ikuti langkah-langkah berikut:
Temukan label versi AlloyDB Omni yang terinstal:
Docker
dockerrun--rm-itgoogle/alloydbomnicatVERSION.txt
Podman
podmanrun--rm-itgoogle/alloydbomnicatVERSION.txt
Outputnya mirip dengan hal berikut ini:
AlloyDB Omni version: 16.8.0
Catat nomor versi AlloyDB Omni karena Anda akan membutuhkannya pada langkah berikutnya.
Buat image Docker kustom yang menyertakan ekstensi orafce:
$~/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
Buat penampung baru dengan AlloyDB Omni bernama my-omni-orafce:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-03 UTC."],[[["\u003cp\u003eAlloyDB Omni does not inherently include the orafce extension, but it can be manually added to enhance functionality with Oracle database features.\u003c/p\u003e\n"],["\u003cp\u003eTo add orafce, users must first identify their installed AlloyDB Omni version using either Docker or Podman commands.\u003c/p\u003e\n"],["\u003cp\u003eA new container needs to be built, using the \u003ccode\u003eDockerfile\u003c/code\u003e and the correct \u003ccode\u003eOMNI_VERSION\u003c/code\u003e environment variable, which includes the necessary \u003ccode\u003epostgresql-15-orafce\u003c/code\u003e package.\u003c/p\u003e\n"],["\u003cp\u003eAfter building the new container, users must create a new AlloyDB Omni container and then connect to the database to enable the orafce extension with the \u003ccode\u003eCREATE EXTENSION IF NOT EXISTS ORAFCE;\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eIt is recommended to avoid using the \u003ccode\u003edbms_utility.format_call_stack\u003c/code\u003e and \u003ccode\u003edbms_output.get_line\u003c/code\u003e functions due to known issues with the orafce extension on AlloyDB Omni.\u003c/p\u003e\n"]]],[],null,["# Install orafce for AlloyDB Omni\n\nSelect a documentation version: Current (16.8.0)keyboard_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/current/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."]]