How to Deploy Oracle Autonomous AI Database@Google on Google Cloud

Oracle AI Database@Google Cloud enables organisations to run Oracle database services on Oracle Cloud infrastructure directly within Google Cloud data centres.

For organisations that already rely on Oracle Database while investing strategically in Google Cloud, the value proposition is straightforward:

  • Modernise without unnecessary re-platforming — retain Oracle database capabilities while moving application development and cloud services closer to Google Cloud.
  • Bring AI closer to enterprise data — combine governed Oracle data with Google Cloud services such as Gemini Enterprise Agent Platform.
  • Reduce multicloud complexity — streamlining procurement process, use the existing Google credits to run the Oracle AI database and procure via Google Marketplace
  • Improve developer productivity — allow developers to build with Python, Java, Node.js, Kubernetes, Streamlit and other Google Cloud services while accessing Oracle Autonomous AI Database.
  • Reduce operational overhead — use Autonomous AI Database capabilities to automate routine database administration, tuning and scaling.
  • Preserve enterprise data governance — keep Oracle Database as the system of record while exposing controlled data and services to cloud-native applications and AI workloads.

High Level Architecture:

 

In this simple demo, I have created an Autonomous AI Database@Google which can only be accessed via private connectivity. 

I have used the public offer model which gives you access to Autonomous AI Database@Google via a PAYG model.

Since it’s a public offer – the linking process will involve provisioning a new OCI cloud account where your Oracle AI database is provisioned.

 

A developer can create a GCP  cloud VM and access the Oracle database through the Google VPC network and the associated ODB Network.

As this is a high level write up, some steps may have been skipped!

Assumption: Account Linking already done!

  1. Provision the Google VPC network on your preferred region (I am using europe-west2 Region. Add an application subnet. 

Subnet rage: 10.1.0.0/24

The important thing to note is that this VPC network will also be associated with your ODB Network. Google describes the ODB Network as the bridge between the Google VPC and the OCI child site hosting the Oracle database services.

2. Create an ODB Network and Subnet

In Google Cloud Console:

Oracle Database@Google Cloud → ODB Networks → Create

Select:

Associated VPC: The VPC Network you created above
Region: europe-west2 (or the region of your VPC)
ODB network: odb-db2-subnet (or your prefered name)

Create a subnet- make sure that the CIDR doesn’t conflict with the existing Google VPC ranges.

Subnet rage: 10.2.0.0/24 

3. Provision the Autonomous AI Database @Google

Instance ID: oracledemo1
Database name: ORACLEDEMO1
Region: europe-west2
Workload: Transaction Processing
ECPU: minimum suitable for demo
Autoscaling: enabled if desired
Storage: minimum suitable for demo
Networking: Private endpoint
ODB Network: <Your ODB Network>
ODB Subnet: <Your ODB Subnet>
Authentication: mTLS

4. Create the Google Compute Engine VM

Create a Google compute vm, place it under the VPC network above using the application subnet you created before. (Allow it to be accessed externally via an external IP.

zone=europe-west2
machine-type=e2-medium
subnet=<app-subnet you created earlier>

Access it using your favorite SSH client. 

(I have done a blog on that here )

5. Download the Autonomous AI Database Wallet and upload it on the compute VM.

In GCP console, go to Autonomous AI Database -> Connections -> Download Wallet

Copy the Zip file to the VM.

Create a dedicated wallet folder:

mkdir -p ~/wallet

Move it:

mv Wallet_ORACLEDEMO1.zip ~/wallet/

Extract it:

cd ~/wallet
unzip Wallet_ORACLEDEMO1.zip

Verify:

ls -lah


For python-oracledb Thin mode, the important files are:

 

tnsnames.ora
ewallet.pem

Oracle specifically documents these two as the required wallet files for Thin mode.

6. Create a Python virtual environment

Run:

python3 -m venv ~/.adb-env

Activate it:

source ~/.adb-env/bin/activate

Upgrade pip:

python -m pip install –upgrade pip

Install Oracle’s driver:

python -m pip install oracledb

7. Create environment variables

export DB_USER='ADMIN'
export DB_PASSWORD='YOUR_DATABASE_PASSWORD'
export WALLET_PASSWORD='YOUR_WALLET_PASSWORD'
export DB_DSN='oracledemo1_high' (from your database naming)
export WALLET_DIR="$HOME/wallet"

Save the above as a file ie. .dbvariables.env -> to run on the VM terminal:

source ~/.dbvariables.env

To verify:

echo "DB_USER=$DB_USER"
echo "DB_DSN=$DB_DSN"
echo "WALLET_DIR=$WALLET_DIR"

[ -n "$DB_PASSWORD" ] && echo "DB_PASSWORD is set"
[ -n "$WALLET_PASSWORD" ] && echo "WALLET_PASSWORD is set"

8.  create a test connection python script (testconnection.py)

import oracledb
import os

WALLET_DIR = "~/wallet"

connection = oracledb.connect(
user=os.environ["DB_USER"],
password=os.environ["DB_PASSWORD"],
dsn=os.environ["DB_DSN"],
config_dir=WALLET_DIR,
wallet_location=WALLET_DIR,
wallet_password=os.environ["WALLET_PASSWORD"],
)

print("Connected!")

cursor = connection.cursor()

cursor.execute("""

SELECT

sys_context('USERENV','DB_NAME'),

sys_context('USERENV','SERVICE_NAME'),

user

FROM dual

""")

db_name, service_name, username = cursor.fetchone()

print(f"Database : {db_name}")

print(f"Service : {service_name}")

print(f"User : {username}")

cursor.execute("""

SELECT

JSON_VALUE(cloud_identity, '$.DATABASE_NAME'),

JSON_VALUE(cloud_identity, '$.PROVIDER_NAME'),

JSON_VALUE(cloud_identity, '$.REGION'),

JSON_VALUE(

JSON_VALUE(cloud_identity, '$.DATABASE_RESOURCE_ID'),

'$.cloud_identifier_string'

)

FROM v$pdbs

WHERE con_id = SYS_CONTEXT('USERENV', 'CON_ID')

""")

display_name, cloud_provider, region, cloud_location = cursor.fetchone()

print(f"Display Name : {display_name}")

print(f"Cloud Provider : {cloud_provider}")

print(f"Region : {region}")

print(f"GCP Cloud Location : {cloud_location}")

cursor.execute("SELECT CURRENT_TIMESTAMP FROM dual")

print("Current Database Time:", cursor.fetchone()[0])

cursor.close()

connection.close()

print("Connection closed successfully...")

9. Run and Test the connection!

Unknown's avatar

Author: Labanish

I am in the field of IT, currently working as a cloud architect. I have experience living and working abroad, spent some years in Romania, then relocated to the UK for work. In my spare time, you will find me biking or hiking, exploring new cities or watching my favorite sport, F1. The views expressed here are mine and do not associate to any organization. Laban.

Leave a Reply

Discover more from The Cloud Adoption Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading