Configure an Amazon RDS Oracle database for CDC

This page describes how to configure change data capture (CDC) to stream data from an Amazon RDS Oracle database to a supported destination, such as BigQuery or Cloud Storage.

You can configure your source Oracle database for use with the following CDC methods:

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 Amazon RDS Oracle database for binary log reader

For Amazon RDS sources, Datastream supports only database directory objects as the log access method for the binary log reader. You need to create the database directories that point to the online redo log files and the archived log files. The names of these directories are static and can't be changed later. You need to provide these names to Datastream when you create your stream.

  1. Connect to your source Amazon RDS instance.

  2. In the terminal, or using the Amazon RDS dashboard, run the following commands:

    BEGIN
    rdsadmin.rdsadmin_master_util.create_archivelog_dir;
    END;
    BEGIN
    rdsadmin.rdsadmin_master_util.create_onlinelog_dir;
    END;
    COMMIT;
    GRANTREADONDIRECTORYONLINELOG_DIRTOUSER_NAME;
    GRANTREADONDIRECTORYARCHIVELOG_DIRTOUSER_NAME;
  3. Verify that your database is running in ARCHIVELOG mode. To do so, sign in to your Oracle database and run the following command at the SQL prompt:

    SELECT LOG_MODE FROM V$DATABASE;

    1. If the result is ARCHIVELOG, then move on to step c.
    2. If the result is NOARCHIVELOG, then you'll need to enable ARCHIVELOG mode for your database.
    3. 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.
    4. Define a data retention policy for your database by running this command:
      execrdsadmin.rdsadmin_util.set_configuration('archivelog retention hours',96);
      We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.
    5. Configure the Oracle log file rotation policy. We recommend setting a maximum log file size to a value lower than 1GB.
  4. Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:

    execrdsadmin.rdsadmin_util.alter_supplemental_logging('ADD');

    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. At the SQL prompt, run the following command to enable supplemental log data for the entire database:

    execrdsadmin.rdsadmin_util.alter_supplemental_logging('ADD','ALL');
  5. Grant the following privileges to the database user:

    execrdsadmin.rdsadmin_util.grant_sys_object('GV_$LOG','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('GV_$LOGFILE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('GV_$ARCHIVED_LOG','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('GV_$INSTANCE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('GV_$STANDBY_LOG','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$INSTANCE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$PDBS','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$TRANSPORTABLE_PLATFORM','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$DATABASE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$PARAMETER','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('COL$','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_OBJECTS','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_TABLESPACES','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_ENCRYPTED_COLUMNS','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_EXTENTS','USER_NAME','SELECT');
    GRANTCONNECTTOUSER_NAME;
    GRANTCREATESESSIONTOUSER_NAME;
    GRANTSELECTANYTABLETOUSER_NAME;

    Replace USER_NAME with the name of the user account that you intend to use to connect to your database.

Configure your Amazon RDS Oracle database for LogMiner

  1. Verify that your database is running in ARCHIVELOG mode. To do so, sign in to your Oracle database and run the following command at the SQL prompt:

    SELECTLOG_MODEFROMV$DATABASE;
    
    1. If the result is ARCHIVELOG, then move on to step c.
    2. If the result is NOARCHIVELOG, then you'll need to enable ARCHIVELOG mode for your database.

      Key point: For your database to run in ARCHIVELOG mode, you must enable backups for the database.

    3. 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.

    4. Define a data retention policy for your database by running this command:

      execrdsadmin.rdsadmin_util.set_configuration('archivelog retention hours',96);
      

      We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.

  2. Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:

    execrdsadmin.rdsadmin_util.alter_supplemental_logging('ADD');
    

    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:

    ALTER TABLE SCHEMA.TABLE ADD SUPPLEMENTAL LOG DATA (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.

    At the SQL prompt, run the following command to enable supplemental log data for the entire database:

    exec rdsadmin.rdsadmin_util.alter_supplemental_logging('ADD','ALL');
    
  3. Grant the appropriate privileges to the user account that will be used to connect to your database. To do so, run the following commands:

    GRANTEXECUTE_CATALOG_ROLETOUSER_NAME;
    GRANTCONNECTTOUSER_NAME;
    GRANTCREATESESSIONTOUSER_NAME;
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$DATABASE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$ARCHIVED_LOG','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$LOG','USER_NAME','SELECT');-- for primary databases
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$STANDBY_LOG','USER_NAME','SELECT');-- for standby databases
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$LOGFILE','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$LOGMNR_LOGS','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$LOGMNR_CONTENTS','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('V_$PARAMETER','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBMS_LOGMNR','USER_NAME','EXECUTE');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBMS_LOGMNR_D','USER_NAME','EXECUTE');
    GRANTSELECTANYTRANSACTIONTOUSER_NAME;
    GRANTSELECTANYTABLETOUSER_NAME;

    If your database uses Transparent Data Encryption (TDE), grant the following permissions:

    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_TABLESPACES','USER_NAME','SELECT');
    execrdsadmin.rdsadmin_util.grant_sys_object('DBA_ENCRYPTED_COLUMNS','USER_NAME','SELECT');

    If your organization doesn't permit granting the GRANT SELECT ANY TABLE permission, 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;
  4. Grant the user account SELECT access to the DBA_EXTENTS view in your database. This privilege lets you use the ROWID based backfill for your Oracle source:

    GRANTSELECTONDBA_EXTENTSTOUSER_NAME;

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年08月26日 UTC.