このページでは、既存の AlloyDB Omni のインストール環境に orafce 拡張機能を手動で追加する方法について説明します。orafce 拡張機能は、Oracle データベースの関数とパッケージのサブセットをエミュレートする関数と演算子を提供します。この拡張機能により、アプリケーションを Oracle から AlloyDB Omni などの PostgreSQL 互換データベースに移行することが容易になります。
始める前に
システムに AlloyDB Omni をインストールします。
AlloyDB Omni に orafce を追加する
AlloyDB Omni に orafce 拡張機能を追加する手順は次のとおりです。
インストールされている AlloyDB Omni バージョンのラベルを確認します。
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
出力は次のようになります。
AlloyDB Omni version: 16.3.0
AlloyDB Omni のバージョン番号をメモします。これは次のステップで必要になります。
orafce 拡張機能を含むカスタム Docker イメージをビルドします。
$ ~/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
AlloyDB Omni を使用して
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
orafce 拡張機能を使用してデータベースに接続します。
docker exec -it my-omni-orafce psql -h localhost -U postgres
orafce を有効にします。
CREATE EXTENSION IF NOT EXISTS ORAFCE;
orafce がインストールされ、有効になっていることを確認します。
SELECT oracle.sysdate();
出力は次のようになります。
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)