AlloyDB Omni tidak menyertakan ekstensi Orafce, tetapi Anda dapat menambahkannya secara manual ke penginstalan AlloyDB Omni yang ada dengan mengikuti petunjuk di halaman ini untuk menyediakan fungsi dan operator tambahan dari database Oracle.
Sebelum memulai
Pastikan Anda telah menginstal AlloyDB Omni di sistem Anda.
Server tunggal
Menambahkan Orafce ke penginstalan AlloyDB Omni
Untuk menambahkan ekstensi Orafce ke penginstalan AlloyDB Omni, ikuti langkah-langkah berikut:
- Temukan label versi AlloyDB Omni yang diinstal:
Docker
docker run --rm -it google/alloydbomni cat VERSION.txt
Podman
podman run --rm -it google/alloydbomni cat VERSION.txt
Outputnya mirip dengan hal berikut ini:
AlloyDB Omni version: 15.5.5
Catat nomor versi AlloyDB Omni; Anda memerlukannya di langkah berikutnya.
- Tetapkan variabel lingkungan
OMNI_VERSION
:OMNI_VERSION=VERSION
Ganti VERSION dengan versi server database lengkap dari langkah sebelumnya—misalnya,
15.5.3
. - Buat penampung AlloyDB Omni baru yang menyertakan Orafce:
Docker
mkdir ~/alloydb-omni-orafce
tee -a ~/alloydb-omni-orafce/Dockerfile << EOF ARG OMNI_VERSION FROM postgres:15-bookworm AS postgres RUN apt-get update && \ apt-get install -y --no-install-recommends \ postgresql-15-orafce && \ apt-get purge -y --auto-remove && \ rm -rf /var/lib/apt/lists/* FROM google/alloydbomni:${OMNI_VERSION} COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/ COPY --from=postgres /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ COPY --from=postgres /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ EOF
cd ~/alloydb-omni-orafce
sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
Podman
mkdir ~/alloydb-omni-orafce
tee -a ~/alloydb-omni-orafce/Dockerfile << EOF ARG OMNI_VERSION FROM postgres:15-bookworm AS postgres RUN apt-get update && \ apt-get install -y --no-install-recommends \ postgresql-15-orafce && \ apt-get purge -y --auto-remove && \ rm -rf /var/lib/apt/lists/* FROM google/alloydbomni:${OMNI_VERSION} COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/ COPY --from=postgres /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ COPY --from=postgres /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ EOF
cd ~/alloydb-omni-orafce
sudo podman build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
Docker
mkdir ~/alloydb-omni-orafce
tee -a ~/alloydb-omni-orafce/Dockerfile << EOF ARG OMNI_VERSION FROM postgres:15-bookworm AS postgres RUN apt-get update && \ apt-get install -y --no-install-recommends \ postgresql-15-orafce && \ apt-get purge -y --auto-remove && \ rm -rf /var/lib/apt/lists/* FROM google/alloydbomni:${OMNI_VERSION} COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/ COPY --from=postgres /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/ COPY --from=postgres /lib/aarch64-linux-gnu/ /lib/aarch64-linux-gnu/ EOF
cd ~/alloydb-omni-orafce
sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
Podman
mkdir ~/alloydb-omni-orafce
tee -a ~/alloydb-omni-orafce/Dockerfile << EOF ARG OMNI_VERSION FROM postgres:15-bookworm AS postgres RUN apt-get update && \ apt-get install -y --no-install-recommends \ postgresql-15-orafce && \ apt-get purge -y --auto-remove && \ rm -rf /var/lib/apt/lists/* FROM google/alloydbomni:${OMNI_VERSION} COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /usr/lib/postgresql/15/lib/orafce.so COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /usr/lib/postgresql/15/share/extension/ COPY --from=postgres /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/ COPY --from=postgres /lib/aarch64-linux-gnu/ /lib/aarch64-linux-gnu/ EOF
cd ~/alloydb-omni-orafce
sudo podman build --build-arg OMNI_VERSION=$OMNI_VERSION --tag google/alloydbomni-with-orafce:$OMNI_VERSION .
- Buat penampung baru dengan AlloyDB Omni bernama
my-omni-orafce
:Docker
docker run --name my-omni-orafce -e POSTGRES_PASSWORD=NEW_PASSWORD -d google/alloydbomni-with-orafce:OMNI_VERSION
Podman
podman run --name my-omni-orafce -e POSTGRES_PASSWORD=NEW_PASSWORD -d google/alloydbomni-with-orafce:OMNI_VERSION
- Hubungkan ke database Anda dengan ekstensi Orafce:
Docker
docker exec -it my-omni-orafce psql -h localhost -U postgres
Podman
podman exec -it my-omni-orafce psql -h localhost -U postgres
- Aktifkan Orafce:
CREATE EXTENSION IF NOT EXISTS ORAFCE;
- Pastikan Orafce telah diinstal dan diaktifkan:
Output-nya terlihat mirip dengan berikut ini:SELECT oracle.sysdate();
postgres=# SELECT oracle.sysdate(); sysdate --------------------- 2024-06-10 16:36:30 (1 row)