Installer orafce pour AlloyDB Omni

Sélectionnez une version de la documentation :

Cette page explique comment ajouter manuellement l'extension orafce à une installation AlloyDB Omni existante. L'extension orafce fournit des fonctions et des opérateurs qui émulent un sous-ensemble de fonctions et de packages à partir de la base de données Oracle. Cette extension simplifie la migration des applications d'Oracle vers des bases de données compatibles avec PostgreSQL, comme AlloyDB Omni.

Avant de commencer

Installez AlloyDB Omni sur votre système.

Ajouter orafce à votre installation AlloyDB Omni

Pour ajouter l'extension orafce à votre installation AlloyDB Omni, procédez comme suit :

  1. Recherchez les libellés de la version d'AlloyDB Omni que vous avez installée :

    Docker

    docker run --rm -it  google/alloydbomni cat VERSION.txt
    

    Podman

    podman run --rm -it  google/alloydbomni cat VERSION.txt
    

    Le résultat ressemble à ce qui suit :

    AlloyDB Omni version: 16.8.0
    

    Notez le numéro de version d'AlloyDB Omni, car vous en aurez besoin à l'étape suivante.

  2. Créez un conteneur AlloyDB Omni incluant orafce :

    Linux

    $ mkdir ~/alloydb-omni-orafce
    
    $ tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
    ARG OMNI_VERSION
    FROM google/alloydbomni:${OMNI_VERSION}
    RUN apt-get update && \
          apt-get install -y --no-install-recommends postgresql-16-orafce && \
          apt-get purge -y --auto-remove && \
          rm -rf /var/lib/apt/lists/*
    EOF
    
    $ cd ~/alloydb-omni-orafce
    
    $ sudo docker build --build-arg OMNI_VERSION=OMNI_VERSION --tag google/alloydbomni-with-orafce:OMNI_VERSION .
    

    MacOS

    $ mkdir ~/alloydb-omni-orafce
    
    $ tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
    ARG OMNI_VERSION
    FROM google/alloydbomni:OMNI_VERSION
    RUN apt-get update && \
          apt-get install -y --no-install-recommends postgresql-16-orafce && \
          apt-get purge -y --auto-remove && \
          rm -rf /var/lib/apt/lists/*
    EOF
    
    $ cd ~/alloydb-omni-orafce
    
    $ sudo docker build --build-arg OMNI_VERSION=OMNI_VERSION --tag google/alloydbomni-with-orafce:OMNI_VERSION .
    

  3. Créez un conteneur avec AlloyDB Omni nommé 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
    
  4. Connectez-vous à votre base de données avec l'extension orafce :

    docker exec -it my-omni-orafce psql -h localhost -U postgres
    
  5. Activez orafce :

    CREATE EXTENSION IF NOT EXISTS ORAFCE;
    
  6. Vérifiez qu'Orafce est installé et activé :

    SELECT oracle.sysdate();
    

    Le résultat ressemble à ce qui suit :

    postgres=# SELECT oracle.sysdate();
    sysdate
    ---------------------
    2024-06-10 16:36:30
    (1 row)