Overview
This page describes how to configure your source Oracle database so that Datastream can pull data from it. Datastream can pull changes to data from on-premises or cloud-hosted Oracle databases, including Oracle relational database service (RDS).
Configure a source Oracle database
Before you can use Datastream to pull data from your source Oracle database, you must configure your database by:
- Setting up archive logging to track changes in your database, such as the
INSERT
,UPDATE
,DELETE
, andRENAME
operations. - Granting the appropriate privileges to the user account that will be used to connect to your database.
- Defining a data retention policy for your database to determine which data will be archived, how long it will be kept, should the data at the end of the retention period be archived or destroyed, and so on.
Datastream currently works with the following types of Oracle databases:
For information about how to configure each of these Oracle database types, expand the sections that follow.
Configure an Amazon RDS for Oracle database
- Verify that your database is running in
ARCHIVELOG
mode. To do so, log 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 step c. - If the result is
NOARCHIVELOG
, then you'll need to enableARCHIVELOG
mode for your database. - 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.
- Define a data retention policy for your database by running this command:
exec rdsadmin.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. - Configure the Oracle log file rotation policy. We recommend setting a maximum log file size to a value below 1GB.
- If the result is
- Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:
exec rdsadmin.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');
- Grant the appropriate privileges to the user account that will be used to connect to your database. To do so, run the following commands:
GRANT EXECUTE_CATALOG_ROLE TO USER_NAME; GRANT CONNECT TO USER_NAME; GRANT CREATE SESSION TO USER_NAME; exec rdsadmin.rdsadmin_util.grant_sys_object('V_$DATABASE','USER_NAME','SELECT'); exec rdsadmin.rdsadmin_util.grant_sys_object('V_$ARCHIVED_LOG','USER_NAME','SELECT'); exec rdsadmin.rdsadmin_util.grant_sys_object('V_$LOGMNR_LOGS','USER_NAME','SELECT'); exec rdsadmin.rdsadmin_util.grant_sys_object('V_$LOGMNR_CONTENTS','USER_NAME','SELECT'); exec rdsadmin.rdsadmin_util.grant_sys_object('DBMS_LOGMNR','USER_NAME','EXECUTE'); exec rdsadmin.rdsadmin_util.grant_sys_object('DBMS_LOGMNR_D','USER_NAME','EXECUTE'); GRANT SELECT ANY TRANSACTION TO USER_NAME; GRANT SELECT ANY TABLE TO USER_NAME;
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:
GRANT LOGMINING TO USER_NAME;
Configure a self-hosted Oracle database
- Verify that your database is running in
ARCHIVELOG
mode. To do so, log 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 step 2. - If the result is
NOARCHIVELOG
, then you'll need to enableARCHIVELOG
mode for your database. - Run the following commands when logged in as
SYSDBA
:SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN;
- 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 / CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 4 DAYS;
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:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
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.
Run the following command to enable supplemental log data for the entire database:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
- Grant the appropriate privileges to the user account that will be used to connect to your database. To do so, run the following commands:
GRANT EXECUTE_CATALOG_ROLE TO USER_NAME; GRANT CONNECT TO USER_NAME; GRANT CREATE SESSION TO USER_NAME; GRANT SELECT ON SYS.V_$DATABASE TO USER_NAME; GRANT SELECT ON SYS.V_$ARCHIVED_LOG TO USER_NAME; GRANT SELECT ON SYS.V_$LOGMNR_CONTENTS TO USER_NAME; GRANT EXECUTE ON DBMS_LOGMNR TO USER_NAME; GRANT EXECUTE ON DBMS_LOGMNR_D TO USER_NAME; GRANT SELECT ANY TRANSACTION TO USER_NAME; GRANT SELECT ANY TABLE TO USER_NAME;
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:
GRANT LOGMINING TO USER_NAME;
Configure a self-hosted Oracle pluggable database
Datastream supports Oracle multi-tenant architecture, where a single container database (CDB)contains one or more pluggable databases (PDBs). Each pluggable database is a self-contained database with a unique ID and name, and can be managed independently.
To configure a self-hosted Oracle pluggable database so that you can use it with Datastream, perform the following steps:
- Verify that your database is running in
ARCHIVELOG
mode. To do so, run the following command from theCDB$ROOT
container:SELECT LOG_MODE FROM V$DATABASE;
- If the result is
ARCHIVELOG
, then move on to step 2. - If the result is
NOARCHIVELOG
, then you'll need to enableARCHIVELOG
mode for your database. - Run the following commands when logged in as
SYSDBA
:SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN;
- 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 the following Oracle Recovery Manager (RMAN) command from the
CDB$ROOT
container:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 4 DAYS;
The command defines the data retention policy for all pluggable databases in your container database.
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 supplemental logging on the database at the
CDB$ROOT
container level by running the following command:ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
Next, choose whether to turn on logging for specific tables or the entire pluggable database.
To log changes only for specific tables, connect to the pluggable database container and 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 multiple 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:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
- Create a common user. A common user has the same identity in the
CDB$ROOT
container and in the pluggable databases. A common user can connect to and perform operations within theCDB$ROOT
container, and within any pluggable database in which it has privileges. The common user name must start withC##
orc##
. - Grant the appropriate privileges to the common user that will be used to connect to your database. Different permissions are required at the
CDB$ROOT
container and pluggable database levels.- Connect to the
CDB$ROOT
container and run the following commands:GRANT CREATE SESSION TO USER_NAME; GRANT SET CONTAINER TO USER_NAME; GRANT SELECT ON SYS.V_$DATABASE TO USER_NAME; GRANT SELECT ON SYS.V_$LOGMNR_CONTENTS TO USER_NAME; GRANT EXECUTE ON DBMS_LOGMNR TO USER_NAME; GRANT EXECUTE ON DBMS_LOGMNR_D TO USER_NAME; GRANT LOGMINING TO USER_NAME; GRANT EXECUTE_CATALOG_ROLE TO USER_NAME;
- Connect to the pluggable database and run the following commands:
GRANT CREATE SESSION TO USER_NAME; GRANT SET CONTAINER TO USER_NAME; GRANT SELECT ANY TABLE TO USER_NAME; GRANT SELECT ON SYS.V_$DATABASE TO USER_NAME; GRANT SELECT ON SYS.V_$ARCHIVED_LOG TO USER_NAME; GRANT SELECT ON DBA_SUPPLEMENTAL_LOGGING TO USER_NAME;
- Connect to the