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!

Connect to a Cloud VM host using VS Code with a Remote SSH extension

On your VS Code install an extension Remote – SSH from Microsoft

Set up your SSH Key:

using your terminal navigate to ~/.ssh

Place your public key on the vm in ~/.ssh/authorized_keys

Make sure permissions are correct:

chmod 700 ~/.ssh

chmod 600 ~/.ssh/authorized_keys

Add the VM to your SSH config
Edit ~/.ssh/config on your laptop:

Host myvm
HostName YOUR_VM_IP_OR_DNS
User YOUR_USERNAME
IdentityFile ~/.ssh/<your private key pair>

ie.

HostName <your public ip> 
Host gcp-vm
User thecloudadoption_blog
IdentityFile ~/.ssh/gcp_vscode
IdentitiesOnly yes

For GCP VMs, SSH Key format:

Generate a SSH key: -> with a comment at the end like below(VM  username)
ssh-keygen -t ed25519 -f ~/.ssh/gcp_vscode -C "thecloudadoption_blog"

Then display the public key, copy on the VM in GCP console

cat ~/.ssh/gcp_vscode.pub

It will look something like:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB... thecloudadoption_blog

Google Cloud accepts that format directly.

Then you can add the private key on your local config file as explained above.

Connect from VS Code

Open VS Code

Press Ctrl+Shift+P

Run: Remote-SSH: Connect to Host…

Pick myvm or your VM name

VS Code opens a window connected to the VM, and you can edit files there directly

Run python Code within VS Code:

Install the python plugin for the VM-> Extensions-> python.

Select the Python interpreter

Press:

⌘⇧P

Type:

Python: Select Interpreter

Choose something like:

/usr/bin/python3

or your virtual environment:

/home/thecloudadoption_blog/venv/bin/python

If no interpreters appear, we’ll need to install Python or point VS Code at it.

Installing a Jupyter Notebook on a Compute instance running OEL8 on OCI

On my last blog post, I described the steps to install a jupyter lab notebook on a local machine running MacOS.

This post will describe the steps to install a Jupyter lab on a compute instance running on Oracle Enterprise Linux 8 (OEL8) on Oracle cloud infrastructure.

Step 1: SSH to the the instance

ssh -i dev-instance-private.key opc@141.147.xx.xxx

Step 2: update and install Dependencies: (use dnf cmd for Oracle linux 8, yum for linux 7 and below)

sudo dnf update -y

Step 3: Install python and pip

  sudo dnf install python3 -y
  sudo dnf install python3-pip -y

Step 4: Verify Python and pip

python3 --version
python3 -m pip --version

Step 5: Create and Activate a Virtual Environment:
create a virtual environment.

python3 -m venv myenv


Activate the environment.

source myenv/bin/activate

Step 6: Install Jupyter lab

pip install jupyterlab

Step 7: Launch Jupyter lab

  jupyter lab

Step 8: Access JupyterLab:

To access JupyterLab from outside the OCI instance, you need to open port 8888 (or the port you’re using) in your OCI security list.


Go to your OCI compute instance VCN and find the security list associated with it. Add an ingress rule to allow traffic on port 8888 (or the port you’re using)

Step 9: SSH Tunneling

To access the jupyter lab web browser, open another terminal and add the cmd:

ssh -i dev-instance-private.key opc@141.147.XX.XXX -L 8888:127.0.0.1:8888

The above cmd allows you to access the web browser of your jupyterlab running on the OCI compute instance in your local machine

After the above step, copy the given url on step 7 on your browser to access the notebook. ie.

http://localhost:8888/lab?token=8a4fe5599d5ec4565b0407a82161f2156a7f9acb6d331c4e

See also;

How to install a Jupyter notebook on a Mac book

Step 1: Install Homebrew if not already installed (Homebrew is a package manager for MacOS)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install Python

brew install python

Step 3: Verify Python installation

python3 --version

You should get something like this below:

Step 4: Install Jupyter Lab using pip command

pip install jupyterlab

Step 5: Verify installation

jupyter lab --version

Step 6: launch Jupyter Notebook

jupyter lab

Jupyter notebook launches on a webpage, on localhost port 8888 or 8889 based on available ports ie. http://localhost:8888/lab

more info- you can add the packages you require in the jupyter lab using pip command: ie Below packages are installed in the Jupiter lab

pip install oci pandas numpy matplotlib scikit-learn

Other cmds;

If you want to list the Jupyter lab sessions running:

juypter lab list

To close a session,close the terminal (ctrl+c) running the jupyter session or open another terminal and close the session using the below cmd

jupyter lab stop 8889

In my case above 8889 was my port number.