Configure a self-managed Oracle database for CDC
Stay organized with collections
Save and categorize content based on your preferences.
This page describes how to configure change data capture (CDC) to stream data from a self-managed Oracle database to a supported destination, such as BigQuery or Cloud Storage.
You can configure your self-managed Oracle database to work with the following CDC methods:
These methods specify how Datastream accesses your log files. For more information about the binary log reader and the LogMiner API, see Work with Oracle database redo log files.
For detailed instructions about how to configure your source Oracle database for each of these methods, see the sections that follow.
Configure your self managed Oracle database for binary log reader
To configure your self-managed Oracle database for use with the binary log reader CDC method, perform the following steps:
Create a database user account to be used by Datastream to connect to your database:
CREATEUSERUSER_NAMEIDENTIFIEDBYUSER_PASSWORD;
Replace the following:
- USER_NAME: the name of the database user account that you want to use to connect to your database.
- USER_PASSWORD: the password for the database user account.
Select one of the following methods to access your log files:
Automatic Storage Management (ASM): if you select this option, you need to create a dedicated ASM connection, and provide its details when you create your connection profile. The user account used for the ASM connection must have the
SYSASMprivilege.To create a new ASM user with the
SYSASMprivilege, run the following commands:CREATEUSERASM_USER_NAMEIDENTIFIEDBYASM_PASSWORD; GRANTSYSASMTOASM_USER_NAME;
Replace the following:
- ASM_USER_NAME: the name of the ASM user.
- ASM_PASSWORD: the password for the ASM user.
Database directories: if you select this option, you need to create database directory objects that point to the redo log files and the archived log files, and grant
READaccess to the directories to your database user:
CREATEDIRECTORYDIRECTORY_NAME_1as'ONLINE_REDO_LOGS_PATH'; CREATEDIRECTORYDIRECTORY_NAME_2as'ARCHIVED_REDO_LOGS_PATH'; GRANTREADONDIRECTORYDIRECTORY_NAME_1toUSER_NAME; GRANTREADONDIRECTORYDIRECTORY_NAME_2toUSER_NAME;
Replace the following:
- DIRECTORY_NAME_1: the name of the directory for the online redo log files.
- DIRECTORY_NAME_2: the name of the directory for the archived redo log files.
- ONLINE_REDO_LOGS_PATH: the path to the directory where online redo log files are to be stored.
- ARCHIVED_REDO_LOGS_PATH: the path to the directory where archived log files are to be stored.
- USER_NAME: the name of the database user account created earlier.
If you select the binary log reader method and use database directories, you need to provide the redo log and archived log directory names when you create your stream.
Verify that your database is running in
ARCHIVELOGmode.To do so, sign in to your Oracle database and run the following command at the SQL prompt:
SELECT LOG_MODE FROM V$DATABASE;- If the result is
ARCHIVELOG, then move on to the next step. - If the result is
NOARCHIVELOG, then you'll need to enableARCHIVELOGmode for your database. Run the following commands when logged in as
SYSDBA:SHUTDOWNIMMEDIATE; STARTUPMOUNT; ALTERDATABASEARCHIVELOG; ALTERDATABASEOPEN;
Archived log files consume disk space, so you'll want to configure the DB_RECOVERY_FILE_DEST_SIZE parameter for your database. Use this parameter to specify (in bytes) the hard limit on the total space to be used by target database recovery files. By setting this parameter, you can manage the tradeoff between protecting the database from running out of disk space and the stream failing because of log position loss.
- If the result is
Define a data retention policy for your database by running these Oracle Recovery Manager (RMAN) commands:
TARGET/ CONFIGURERETENTIONPOLICYTORECOVERYWINDOWOF4DAYS;
We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.
Return to the SQL prompt of the database tool that you're using to configure the Oracle log file rotation policy. We recommend setting a maximum log file size of no more than 512MB.
Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:
ALTERDATABASEADDSUPPLEMENTALLOGDATA;
Next, choose whether to turn on logging for specific tables or the entire database.
To log changes only for specific tables, run the following command for each table that you want to replicate:
ALTERTABLESCHEMA.TABLEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
Replace the following:
- SCHEMA: the name of the schema that contains the table.
- TABLE: the name of the table for which you want to log changes.
To replicate most or all tables in your database, consider turning logging on for the entire database. Run the following command to enable supplemental log data for the entire database:
ALTERDATABASEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
Grant the appropriate privileges directly to the user account that's used to connect to your database. Note that these grants don't work when assigned to a role, for example. To do so, run the following commands:
GRANTSELECTONGV_$LOGTOUSER_NAME; GRANTSELECTONGV_$LOGFILETOUSER_NAME; GRANTSELECTONGV_$ARCHIVED_LOGTOUSER_NAME; GRANTSELECTONGV_$INSTANCETOUSER_NAME; GRANTSELECTONGV_$STANDBY_LOGTOUSER_NAME; GRANTSELECTONV_$INSTANCETOUSER_NAME; GRANTSELECTONV_$PDBSTOUSER_NAME; GRANTSELECTONV_$TRANSPORTABLE_PLATFORMTOUSER_NAME; GRANTSELECTONV_$DATABASETOUSER_NAME; GRANTSELECTONV_$PARAMETERTOUSER_NAME; GRANTSELECTONCOL$TOUSER_NAME; GRANTSELECTONDBA_OBJECTSTOUSER_NAME; GRANTSELECTONDBA_TABLESPACESTOUSER_NAME; GRANTSELECTONDBA_ENCRYPTED_COLUMNSTOUSER_NAME; GRANTSELECTONDBA_EXTENTSTOUSER_NAME; GRANTCONNECTTOUSER_NAME; GRANTCREATESESSIONTOUSER_NAME; GRANTSELECTANYTABLETOUSER_NAME;
Replace USER_NAME with the name of the database user account created earlier.
Configure your self managed Oracle database for LogMiner
Create a database user account to be used by Datastream to connect to your database:
CREATEUSERUSER_NAMEIDENTIFIEDBYUSER_PASSWORD;
Replace the following:
- USER_NAME: the name of the database user account that you want to use to connect to your database.
- USER_PASSWORD: the password for the database user account.
Verify that your database is running in
ARCHIVELOGmode.To do so, sign in to your Oracle database and run the following command at the SQL prompt:
SELECT LOG_MODE FROM V$DATABASE;- If the result is
ARCHIVELOG, then move on to the next step. - If the result is
NOARCHIVELOG, then you need to enableARCHIVELOGmode for your database. Run the following commands when logged in as
SYSDBA:SHUTDOWNIMMEDIATE; STARTUPMOUNT; ALTERDATABASEARCHIVELOG; ALTERDATABASEOPEN;
Archived log files consume disk space, so you'll want to configure the DB_RECOVERY_FILE_DEST_SIZE parameter for your database. Use this parameter to specify (in bytes) the hard limit on the total space to be used by target database recovery files. By setting this parameter, you can manage the tradeoff between protecting the database from running out of disk space and the stream failing because of log position loss.
- If the result is
Define a data retention policy for your database by running these Oracle Recovery Manager (RMAN) commands:
TARGET/ CONFIGURERETENTIONPOLICYTORECOVERYWINDOWOF4DAYS;
We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.
Return to the SQL prompt of the database tool that you're using to configure the Oracle log file rotation policy. We recommend setting a maximum log file size of no more than 512MB.
Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:
ALTERDATABASEADDSUPPLEMENTALLOGDATA;
Next, choose whether to turn on logging for specific tables or the entire database.
To log changes only for specific tables, run the following command for each table that you want to replicate:
ALTERTABLESCHEMA.TABLEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
Replace the following:
- SCHEMA: the name of the schema that contains the table.
- TABLE: the name of the table for which you want to log changes.
To replicate most or all tables in your database, consider turning logging on for the entire database. Run the following command to enable supplemental log data for the entire database:
ALTERDATABASEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
Grant the appropriate privileges directly to the user account that's used to connect to your database. Note that these grants don't work when assigned to a role, for example. To do so, run the following commands:
GRANTEXECUTE_CATALOG_ROLETOUSER_NAME; GRANTCONNECTTOUSER_NAME; GRANTCREATESESSIONTOUSER_NAME; GRANTSELECTONSYS.V_$DATABASETOUSER_NAME; GRANTSELECTONSYS.V_$LOGTOUSER_NAME;-- for primary databases GRANTSELECTONSYS.V_$STANDBY_LOGTOUSER_NAME;-- for standby databases GRANTSELECTONSYS.V_$LOGFILETOUSER_NAME; GRANTSELECTONSYS.V_$ARCHIVED_LOGTOUSER_NAME; GRANTSELECTONSYS.V_$LOGMNR_CONTENTSTOUSER_NAME; GRANTSELECTONSYS.V_$PARAMETERTOUSER_NAME; GRANTEXECUTEONDBMS_LOGMNRTOUSER_NAME; GRANTEXECUTEONDBMS_LOGMNR_DTOUSER_NAME; GRANTSELECTANYTRANSACTIONTOUSER_NAME; GRANTSELECTANYTABLETOUSER_NAME;
If your database uses Transparent Data Encryption (TDE), grant the following permissions:
GRANTSELECTONDBA_TABLESPACESTOUSER_NAME; GRANTSELECTONDBA_ENCRYPTED_COLUMNSTOUSER_NAME;
If your organization doesn't permit granting the
GRANT SELECT ANY TABLEpermission, use the solution described in the Oracle change data capture (CDC) section of the Datastream FAQ page.If your source database is Oracle 12c or newer, then grant the following additional privilege:
GRANTLOGMININGTOUSER_NAME;
Grant the user account
SELECTaccess to theDBA_EXTENTSview in your database. This privilege lets you use theROWIDbased backfill for your Oracle source:GRANTSELECTONDBA_EXTENTSTOUSER_NAME;
What's next
- Learn more about how Datastream works with Oracle sources.