Use AI Models in OCI GoldenGate to Create Vector Embeddings
Learn how to generate vector embeddings using the AI Service in Data replication deployments using GoldenGate 26ai and higher.
Overview
OCI GoldenGate includes an AI Service that allows GoldenGate processes to interact with AI models from various providers (OCI Generative AI, OpenAI, Google Gemini, and Voyage AI) to generate vector embeddings directly within data replication pipelines.
The following steps guide you through how to set up connectivity to AI Models and use them to generate vector embeddings in a Replicat.
Before you begin
You must have the following in order to proceed:
-
An existing source database.
-
An existing target Oracle AI Database supporting vectors, such as Oracle Autonomous AI Lakehouse.
-
If you use Oracle Autonomous AI Database, unlock the GGADMIN user.
-
The source and target database must be in the same tenancy and region.
-
If you need sample data, download Archive.zip, and then follow the instructions in Lab 1, Task 3: Load the ATP schema.
-
An existing OCI API key.
-
An existing OCI Vault containing the private API key content.
-
The minimum recommended policies to use OCI GoldenGate.
-
The minimum recommended policies to use OCI Generative AI.
Task 1: Set up the environment
-
Create a source Oracle Autonomous AI Transaction Processing (ATP) connection.
-
Create a target Oracle Autonomous AI Lakehouse (ALK) connection.
-
Use a SQL tool to enable supplemental logging on the source database:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; -
Run the following query in the SQL tool to ensure that support_mode=FULL for all tables in the source database:
select * from DBA_GOLDENGATE_SUPPORT_MODE where owner = 'SRC_OCIGGLL'; -
Create the following table on the target ALK database to store the vector embedding that will be created using the OpenAI text-embedding-3-small model:
CREATE TABLE "SRCMIRROR_OCIGGLL"."SRC_CITY_VECTOR" ( "CITY_ID" NUMBER(10,0), "CITY" VARCHAR2(50 BYTE), "REGION_ID" NUMBER(10,0), "POPULATION" NUMBER(10,0), "CITY_EMBED" VECTOR(1536,FLOAT32) );
Task 2: Configure the AI Model
-
Create an AI Model Connection
-
Name: OCI_GenAI_TextEmbeddingSmall
-
Type: AI Model
-
Provider type: OCI Generative AI
-
Authentication type: OCI Generative AI
-
User: Use current tenancy and user
-
Specify the region
-
Provide or create a Secret containing the OCI API Key
-
Enter the API Key fingerprint
-
Select an embedding model from the list, such as openai.text-embedding-3-small
-
Select Create
-
-
Review the Connection details
-
Assign the AI Model connection to your deployment:
-
Go to your Deployment details page, select Assigned connections
-
Select Assign connection in the Assigned AI model connections section, and then select the AI Model connection.
-
Select Assign connection to confirm the assignment
-
-
Ensure the new AI Model connection is listed in the Assigned AI model connections section.
-
Assigning the AI Model connection to the deployment automatically configures the AI Service in GoldenGate
-
Log into the OCI GoldenGate console, go to AI Models and review the list of AI models.
-
Take note of the Model Name as you will need it to use the @AISERVICE function in a Replicat to create the vector embedding
-
The model name in the
@AISERVICEfunction must match the Model Name shown in OCI GoldenGate AI Models. It may be different from the connection name.
-
Task 3: Create the Integrated Extract
An Integrated Extract captures ongoing changes to source database.
-
On the deployment Details page, select Launch console.
-
If required, enter oggadmin for User name and the password you used when creating the deployment, and then select Sign In.
-
Add Transaction Data and a Checkpoint Table:
-
Open the navigation menu and then select DB Connections.
-
Select Connect to database SourceDB.
-
In the navigation menu, select Trandata, and then select Add Trandata (plus icon).
-
For Schema Name, enter
SRC_OCIGGLL, and then select Submit. -
To verify, enter
SRC_OCIGGLLinto the Search field and select Search. -
Open the navigation menu and then select DB Connections.
-
Select Connect to database TargetDB.
-
In the navigation menu, select Checkpoint, and then select Add Checkpoint (plus icon).
-
For Checkpoint Table, enter
"SRCMIRROR_OCIGGLL"."CHECKTABLE", and then select Submit.
-
-
Note: See additional extract parameter options for more information about parameters that you can use to specify source tables.
On the Extract Parameters page, append the following lines under
EXTTRAIL <trail-name>:-- Capture DDL operations for listed schema tables ddl include mapped -- Add step-by-step history of to the report file. Useful when troubleshooting. ddloptions report -- Write capture stats per table to the report file daily. report at 00:01 -- Rollover the report file weekly. Useful when IE runs -- without being stopped/started for long periods of time to -- keep the report files from becoming too large. reportrollover at 00:01 on Sunday -- Report total operations captured, and operations per second -- every 10 minutes. reportcount every 10 minutes, rate -- Table list for capture table SRC_OCIGGLL.*; -
Check for long running transactions. Run the following script on your source database:
select start_scn, start_time from gv$transaction where start_scn < (select max(start_scn) from dba_capture);If the query returns any rows, then you must locate the transaction's SCN and then either commit or rollback the transaction.
Task 4: Add and run a Non-integrated Replicat
-
On the Parameter File screen, replace
MAP *.*, TARGET *.*;with the following script:-- Capture DDL operations for listed schema tables ddl include mapped -- -- Add step-by-step history of ddl operations captured -- to the report file. Very useful when troubleshooting. ddloptions report -- -- Write capture stats per table to the report file daily. report at 00:01 -- -- Rollover the report file weekly. Useful when PR runs -- without being stopped/started for long periods of time to -- keep the report files from becoming too large. reportrollover at 00:01 on Sunday -- -- Report total operations captured, and operations per second -- every 10 minutes. reportcount every 10 minutes, rate -- -- Table map list for apply MAP SRC_OCIGGLL.SRC_CITY, TARGET SRCMIRROR_OCIGGLL.SRC_CITY_VECTOR, COLMAP ( USEDEFAULTS, CITY_EMBED = @AISERVICE(embed,'OCI_GenAI_TextEmbeddingSmall',CITY) );Note
The @AISERVICE function creates a vector embedding from the data stored in the CITY column using the AI Model connection defined earlier.
-
Perform Inserts to the source database:
-
Return to the Oracle Cloud console and use the navigation menu to navigate back to Oracle AI Database, Autonomous AI Transaction Processing, and then SourceDB.
-
On the SourceDB Details page, select Database actions, and then select SQL.
-
Enter the following inserts, and then select Run Script:
Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1000,'Houston',20,743113); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1001,'Dallas',20,822416); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1002,'San Francisco',21,157574); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1003,'Los Angeles',21,743878); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1004,'San Diego',21,840689); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1005,'Chicago',23,616472); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1006,'Memphis',23,580075); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1007,'New York City',22,124434); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1008,'Boston',22,275581); Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1009,'Washington D.C.',22,688002); -
In the OCI GoldenGate Deployment Console, select the Extract name (UAEXT), and then select Statistics. Verify that SRC_OCIGGLL.SRC_CITY is listed with 10 inserts.
-
Go back to the Overview screen, select the Replicat name (REP), and then select Statistics. Verify that SRCMIRROR_OCIGGLL.SRC_CITY is listed with 10 inserts
-
Go to your target Autonomous AI Lakehouse Details page, select Database Actions, then select SQL
-
In SQL, run
select * from SRCMIRROR_OCIGGLL.SRC_CITY_VECTOR;and review the results, including the vector embeddings created by OCI GoldenGate using the AI Service.
-
The SRCMIRROR_OCIGGLL.SRC_CITY_VECTOR table contains rows replicated from SRC_OCIGGLL.SRC_CITY, and the CITY_EMBED column contains a generated vector embedding for each city.
Troubleshooting
-
If the Replicat cannot call the model, verify that the AI Model connection is successfully assigned to the deployment.
-
If authentication fails, verify the OCI API key secret, fingerprint, user, tenancy, and region.
-
If rows are replicated but embeddings are not generated, confirm that the model name in
@AISERVICEmatches the Model Name listed in OCI GoldenGate AI Models. -
If the Replicat fails on the target table, verify that the target database supports vector columns and that
CITY_EMBEDis defined with dimensions compatible with the selected embedding model. -
If capture fails or tables are skipped, confirm that supplemental logging is enabled and that the source table support mode is
FULL.