Implicit capture means that a capture process or a synchronous capture captures and enqueues database changes automatically. A capture process captures changes in the redo log, while a synchronous capture captures data manipulation language (DML) changes with an internal mechanism. Both capture processes and synchronous captures reformat the captured changes into logical change records (LCRs) and enqueue the LCRs into an ANYDATA
queue.
The following topics describe configuring implicit capture:
Each task described in this chapter should be completed by an Oracle Streams administrator that has been granted the appropriate privileges, unless specified otherwise.
See Also:
Oracle Streams Concepts and Administration for more information about implicit capture
"Configuring an Oracle Streams Administrator on All Databases"
You can create a capture process that captures changes either locally at the source database or remotely at a downstream database. A downstream capture process runs on a downstream database, and redo data from the source database is copied to the downstream database. A downstream capture process captures changes in the copied redo data at the downstream database.
You can use any of the following procedures to create a local capture process:
Each of the procedures in the DBMS_STREAMS_ADM
package creates a capture process with the specified name if it does not already exist, creates either a positive rule set or negative rule set for the capture process if the capture process does not have such a rule set, and can add table rules, schema rules, or global rules to the rule set.
The CREATE_CAPTURE
procedure creates a capture process, but does not create a rule set or rules for the capture process. However, the CREATE_CAPTURE
procedure enables you to specify an existing rule set to associate with the capture process, either as a positive or a negative rule set, a first SCN, and a start SCN for the capture process. Also, to create a capture process that performs downstream capture, you must use the CREATE_CAPTURE
procedure.
The following sections describe configuring a capture process:
Caution:
When a capture process is started or restarted, it might need to scan redo log files with aFIRST_CHANGE#
value that is lower than start SCN. Removing required redo log files before they are scanned by a capture process causes the capture process to abort. You can query the DBA_CAPTURE
data dictionary view to determine the first SCN, start SCN, and required checkpoint SCN for a capture process. A capture process needs the redo log file that includes the required checkpoint SCN, and all subsequent redo log files. See Oracle Streams Concepts and Administration for more information about the first SCN and start SCN for a capture process.You can configure an entire Oracle Streams environment, including capture processes, using procedures in the DBMS_STREAMS_ADM
package or Oracle Enterprise Manager. See Chapter 2, "Simple Oracle Streams Replication Configuration".
After creating a capture process, avoid changing the DBID
or global name of the source database for the capture process. If you change either the DBID
or global name of the source database, then the capture process must be dropped and re-created. See "Changing the DBID or Global Name of a Source Database".
To configure downstream capture, the source database must be an Oracle Database 10g Release 1 or later database.
The following tasks must be completed before you configure a capture process:
Complete the following tasks in "Tasks to Complete Before Configuring Oracle Streams Replication".
If you plan to create a real-time or an archived-log downstream capture process that uses redo transport services to transfer archived redo log files to the downstream database automatically, then complete the steps in "Configuring Log File Transfer to a Downstream Capture Database".
If you plan to create a real-time downstream capture process, then complete the steps in "Adding Standby Redo Logs for Real-Time Downstream Capture".
Create an ANYDATA
queue to associate with the capture process, if one does not exist. See "Creating an ANYDATA Queue" for instructions. The examples in this chapter assume that the queue used by the capture process is strmadmin.streams_queue
. Create the queue on the same database that will run the capture process.
The following sections describe using the DBMS_STREAMS_ADM
package and the DBMS_CAPTURE_ADM
package to create a local capture process.
This section contains the following examples:
To configure a local capture process using the DBMS_STREAMS_ADM
package, complete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process".
In SQL*Plus, connect to the source database as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for instructions about connecting to a database in SQL*Plus.
Run the ADD_TABLE_RULES
procedure in the DBMS_STREAMS_ADM
package to create a local capture process:
BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'hr.employees', streams_type => 'capture', streams_name => 'strm01_capture', queue_name => 'strmadmin.streams_queue', include_dml => TRUE, include_ddl => TRUE, include_tagged_lcr => FALSE, source_database => NULL, inclusion_rule => TRUE); END; /
Running this procedure performs the following actions:
Creates a capture process named strm01_capture
. The capture process is created only if it does not already exist. If a new capture process is created, then this procedure also sets the start SCN to the point in time of creation.
Associates the capture process with the existing queue strmadmin.streams_queue
.
Creates a positive rule set and associates it with the capture process, if the capture process does not have a positive rule set. The rule set is a positive rule set because the inclusion_rule
parameter is set to TRUE
. The rule set uses the SYS.STREAMS$_EVALUATION_CONTEXT
evaluation context. The rule set name is system generated.
Creates two rules. One rule evaluates to TRUE
for data manipulation language (DML) changes to the hr.employees
table, and the other rule evaluates to TRUE
for data definition language (DDL) changes to the hr.employees
table. The rule names are system generated.
Adds the two rules to the positive rule set associated with the capture process. The rules are added to the positive rule set because the inclusion_rule
parameter is set to TRUE
.
Specifies that the capture process captures a change in the redo log only if the change has a NULL
tag, because the include_tagged_lcr
parameter is set to FALSE
. This behavior is accomplished through the system-created rules for the capture process.
Creates a capture process that captures local changes to the source database because the source_database
parameter is set to NULL
. For a local capture process, you can also specify the global name of the local database for this parameter.
Prepares the hr.employees
table for instantiation.
Enables supplemental logging for any primary key, unique key, bitmap index, and foreign key columns in the hr.employees
table.
If necessary, complete the steps described in "After Configuring a Capture Process".
See Also:
Oracle Streams Concepts and Administration for more information about rules
To configure a local capture process using the DBMS_CAPTURE_ADM
package, complete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process".
In SQL*Plus, connect to the source database as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for instructions about connecting to a database in SQL*Plus.
Create the rule set that will be used by the capture process if it does not exist. In this example, assume that the rule set is strmadmin.strm01_rule_set
. Optionally, you can also add rules to the rule set. See Oracle Streams Concepts and Administration for instructions.
Run the CREATE_CAPTURE
procedure in the DBMS_CAPTURE_ADM
package to create a local capture process:
BEGIN DBMS_CAPTURE_ADM.CREATE_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'strm02_capture', rule_set_name => 'strmadmin.strm01_rule_set', start_scn => NULL, source_database => NULL, first_scn => NULL); END; /
Running this procedure performs the following actions:
Creates a capture process named strm02_capture
. A capture process with the same name must not exist.
Associates the capture process with the existing queue strmadmin.streams_queue
.
Associates the capture process with the existing rule set strmadmin.strm01_rule_set
. This rule set is the positive rule set for the capture process.
Creates a capture process that captures local changes to the source database because the source_database
parameter is set to NULL
. For a local capture process, you can also specify the global name of the local database for this parameter.
Specifies that the Oracle database determines the start SCN and first SCN for the capture process because both the start_scn
parameter and the first_scn
parameter are set to NULL
.
If no other capture processes that capture local changes are running on the local database, then the BUILD
procedure in the DBMS_CAPTURE_ADM
package is run automatically. Running this procedure extracts the data dictionary to the redo log, and a LogMiner data dictionary is created when the capture process is started for the first time.
If necessary, complete the steps described in "After Configuring a Capture Process".
See Also:
Oracle Streams Concepts and Administration for more information about rulesThis example runs the CREATE_CAPTURE
procedure in the DBMS_CAPTURE_ADM
package to create a local capture process with a start SCN set to 223525
. This example assumes that there is at least one local capture process at the database, and that this capture process has taken at least one checkpoint. You can always specify a start SCN for a new capture process that is equal to or greater than the current SCN of the source database. To specify a start SCN that is lower than the current SCN of the database, the specified start SCN must be higher than the lowest first SCN for an existing local capture process that has been started successfully at least once and has taken at least one checkpoint.
You can determine the first SCN for existing capture processes, and whether these capture processes have taken a checkpoint, by running the following query:
SELECT CAPTURE_NAME, FIRST_SCN, MAX_CHECKPOINT_SCN FROM DBA_CAPTURE;
Your output looks similar to the following:
CAPTURE_NAME FIRST_SCN MAX_CHECKPOINT_SCN ------------------------------ ---------- ------------------ CAPTURE_SIMP 223522 230825
These results show that the capture_simp
capture process has a first SCN of 223522
. Also, this capture process has taken a checkpoint because the MAX_CHECKPOINT_SCN
value is non-NULL
. Therefore, the start SCN for the new capture process can be set to 223522
or higher.
To configure a local capture process with a non-NULL
start SCN, complete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process".
In SQL*Plus, connect to the source database as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for instructions about connecting to a database in SQL*Plus.
Create the rule set that will be used by the capture process if it does not exist. In this example, assume that the rule set is strmadmin.strm01_rule_set
. Optionally, you can also add rules to the rule set. See Oracle Streams Concepts and Administration for instructions.
Run the following procedure to create the capture process:
BEGIN DBMS_CAPTURE_ADM.CREATE_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'strm03_capture', rule_set_name => 'strmadmin.strm01_rule_set', start_scn => 223525, source_database => NULL, first_scn => NULL); END; /
Running this procedure performs the following actions:
Creates a capture process named strm03_capture
. A capture process with the same name must not exist.
Associates the capture process with the existing queue strmadmin.streams_queue
.
Associates the capture process with the existing rule set strmadmin.strm01_rule_set
. This rule set is the positive rule set for the capture process.
Specifies 223525
as the start SCN for the capture process. The new capture process uses the same LogMiner data dictionary as one of the existing capture processes. Oracle Streams automatically chooses which LogMiner data dictionary to share with the new capture process. Because the first_scn
parameter was set to NULL
, the first SCN for the new capture process is the same as the first SCN of the existing capture process whose LogMiner data dictionary was shared. In this example, the existing capture process is capture_simp
.
Creates a capture process that captures local changes to the source database because the source_database
parameter is set to NULL
. For a local capture process, you can also specify the global name of the local database for this parameter.
Note:
If no local capture process exists when the procedure in this example is run, then theDBMS_CAPTURE_ADM.BUILD
procedure is run automatically during capture process creation to extract the data dictionary into the redo log. The first time the new capture process is started, it uses this redo data to create a LogMiner data dictionary. In this case, a specified start_scn
parameter value must be equal to or higher than the current database SCN.If necessary, complete the steps described in "After Configuring a Capture Process".
See Also:
Oracle Database PL/SQL Packages and Types Reference for more information about setting the first_scn
and start_scn
parameters in the CREATE_CAPTURE
procedure
This section describes configuring a real-time or archived-log downstream capture process.
This section contains these topics:
To create a capture process that performs downstream capture, you must use the CREATE_CAPTURE
procedure. The example in this section describes creating a real-time downstream capture process that uses a database link to the source database. However, a real-time downstream capture process might not use a database link.
This example assumes the following:
The source database is dbs1.example.com
and the downstream database is dbs2.example.com
.
The capture process that will be created at dbs2.example.com
uses the strmadmin.streams_queue
.
The capture process will capture DML changes to the hr.departments
table.
This section contains an example that runs the CREATE_CAPTURE
procedure in the DBMS_CAPTURE_ADM
package to create a real-time downstream capture process at the dbs2.example.com
downstream database that captures changes made to the dbs1.example.com
source database. The capture process in this example uses a database link to dbs1.example.com
for administrative purposes. The name of the database link must match the global name of the source database.
Note:
You can configure multiple real-time downstream capture processes that captures changes from the same source database, but you cannot configure real-time downstream capture for multiple source databases at one downstream database.See Also:
Oracle Streams Concepts and Administration for conceptual information about real-time downstream captureComplete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process". Ensure that you complete the tasks "Configuring Log File Transfer to a Downstream Capture Database" and "Adding Standby Redo Logs for Real-Time Downstream Capture".
In SQL*Plus, connect to the downstream database dbs2.example.com
as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
Create the database link from dbs2.example.com
to dbs1.example.com
. For example, if the user strmadmin
is the Oracle Streams administrator on both databases, then create the following database link:
CREATE DATABASE LINK dbs1.example.com CONNECT TO strmadmin
IDENTIFIED BY password
USING 'dbs1.example.com';
This example assumes that an Oracle Streams administrator exists at the source database dbs1.example.com
. If no Oracle Streams administrator exists at the source database, then the Oracle Streams administrator at the downstream database should connect to a user who allows remote access by an Oracle Streams administrator. You can enable remote access for a user by specifying the user as the grantee when you run the GRANT_REMOTE_ADMIN_ACCESS
procedure in the DBMS_STREAMS_AUTH
package at the source database.
Run the CREATE_CAPTURE
procedure to create the capture process:
BEGIN DBMS_CAPTURE_ADM.CREATE_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'real_time_capture', rule_set_name => NULL, start_scn => NULL, source_database => 'dbs1.example.com', use_database_link => TRUE, first_scn => NULL, logfile_assignment => 'implicit'); END; /
Running this procedure performs the following actions:
Creates a capture process named real_time_capture
at the downstream database dbs2.example.com
. A capture process with the same name must not exist.
Associates the capture process with an existing queue on dbs2.example.com
named streams_queue
and owned by strmadmin
.
Specifies that the source database of the changes that the capture process will capture is dbs1.example.com
.
Specifies that the capture process uses a database link with the same name as the source database global name to perform administrative actions at the source database.
Specifies that the capture process accepts redo data implicitly from dbs1.example.com
. Therefore, the capture process scans the standby redo log at dbs2.example.com
for changes that it must capture. If the capture process falls behind, then it scans the archived redo log files written from the standby redo log.
This step does not associate the capture process real_time_capture
with any rule set. A rule set will be created and associated with the capture process in a later step.
If no other capture process at dbs2.example.com
is capturing changes from the dbs1.example.com
source database, then the DBMS_CAPTURE_ADM.BUILD
procedure is run automatically at dbs1.example.com
using the database link. Running this procedure extracts the data dictionary at dbs1.example.com
to the redo log, and a LogMiner data dictionary for dbs1.example.com
is created at dbs2.example.com
when the capture process real_time_capture
is started for the first time at dbs2.example.com
.
If multiple capture processes at dbs2.example.com
are capturing changes from the dbs1.example.com
source database, then the new capture process real_time_capture
uses the same LogMiner data dictionary for dbs1.example.com
as one of the existing archived-log capture process. Oracle Streams automatically chooses which LogMiner data dictionary to share with the new capture process.
Note:
During the creation of a downstream capture process, if thefirst_scn
parameter is set to NULL
in the CREATE_CAPTURE
procedure, then the use_database_link
parameter must be set to TRUE
. Otherwise, an error is raised.See Also:
Oracle Streams Concepts and Administration for more information about SCN values related to a capture processSet the downstream_real_time_mine
capture process parameter to Y
:
BEGIN DBMS_CAPTURE_ADM.SET_PARAMETER( capture_name => 'real_time_capture', parameter => 'downstream_real_time_mine', value => 'Y'); END; /
Create the positive rule set for the capture process and add a rule to it:
BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'hr.departments', streams_type => 'capture', streams_name => 'real_time_capture', queue_name => 'strmadmin.streams_queue', include_dml => TRUE, include_ddl => FALSE, include_tagged_lcr => FALSE, source_database => 'dbs1.example.com', inclusion_rule => TRUE); END; /
Running this procedure performs the following actions:
Creates a rule set at dbs2.example.com
for capture process real_time_capture
. The rule set has a system-generated name. The rule set is the positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
Creates a rule that captures data manipulation language (DML) changes to the hr.departments
table, and adds the rule to the positive rule set for the capture process. The rule has a system-generated name. The rule is added to the positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
Prepares the hr.departments
table at dbs1.example.com
for instantiation using the database link created in Step 3.
Enables supplemental logging for any primary key, unique key, bitmap index, and foreign key columns in the table at dbs1.example.com
.
Connect to the source database dbs1.example.com
as an administrative user with the necessary privileges to switch log files.
Archive the current log file at the source database:
ALTER SYSTEM ARCHIVE LOG CURRENT;
Archiving the current log file at the source database starts real time mining of the source database redo log.
If the capture process appears to be waiting for redo data for an inordinately long time, then check the alert log for errors. See Oracle Streams Concepts and Administration for more information.
If necessary, complete the steps described in "After Configuring a Capture Process".
This section describes configuring an archived-log downstream capture process that either assigns log files implicitly or explicitly.
This section contains these topics:
Configuring an Archived-Log Downstream Capture Process that Assigns Logs Implicitly
Configuring an Archived-Log Downstream Capture Process that Assigns Logs Explicitly
To create a capture process that performs downstream capture, you must use the CREATE_CAPTURE
procedure. The example in this section describes creating an archived-log downstream capture process that uses a database link to the source database for administrative purposes. The name of the database link must match the global name of the source database.
This example assumes the following:
The source database is dbs1.example.com
and the downstream database is dbs2.example.com
.
The capture process that will be created at dbs2.example.com
uses the streams_queue
owned by strmadmin
.
The capture process will capture data manipulation language (DML) changes made to the hr.departments
table at dbs1.example.com
.
The capture process assigns log files implicitly. That is, the downstream capture process automatically scans all redo log files added by redo transport services or added manually from the source database to the downstream database.
Complete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process". Ensure that you complete the task "Configuring Log File Transfer to a Downstream Capture Database".
In SQL*Plus, connect to the downstream database dbs2.example.com
as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
Create the database link from dbs2.example.com
to dbs1.example.com
. For example, if the user strmadmin
is the Oracle Streams administrator on both databases, then create the following database link:
CREATE DATABASE LINK dbs1.example.com CONNECT TO strmadmin
IDENTIFIED BY password
USING 'dbs1.example.com';
This example assumes that an Oracle Streams administrator exists at the source database dbs1.example.com
. If no Oracle Streams administrator exists at the source database, then the Oracle Streams administrator at the downstream database should connect to a user who allows remote access by an Oracle Streams administrator. You can enable remote access for a user by specifying the user as the grantee when you run the GRANT_REMOTE_ADMIN_ACCESS
procedure in the DBMS_STREAMS_AUTH
package at the source database.
Run the CREATE_CAPTURE
procedure to create the capture process:
BEGIN DBMS_CAPTURE_ADM.CREATE_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'strm04_capture', rule_set_name => NULL, start_scn => NULL, source_database => 'dbs1.example.com', use_database_link => TRUE, first_scn => NULL, logfile_assignment => 'implicit'); END; /
Running this procedure performs the following actions:
Creates a capture process named strm04_capture
at the downstream database dbs2.example.com
. A capture process with the same name must not exist.
Associates the capture process with an existing queue on dbs2.example.com
named streams_queue
and owned by strmadmin
.
Specifies that the source database of the changes that the capture process will capture is dbs1.example.com
.
Specifies that the capture process accepts new redo log files implicitly from dbs1.example.com
. Therefore, the capture process scans any new log files copied from dbs1.example.com
to dbs2.example.com
for changes that it must capture.
This step does not associate the capture process strm04_capture
with any rule set. A rule set will be created and associated with the capture process in the next step.
If no other capture process at dbs2.example.com
is capturing changes from the dbs1.example.com
source database, then the DBMS_CAPTURE_ADM.BUILD
procedure is run automatically at dbs1.example.com
using the database link. Running this procedure extracts the data dictionary at dbs1.example.com
to the redo log, and a LogMiner data dictionary for dbs1.example.com
is created at dbs2.example.com
when the capture process is started for the first time at dbs2.example.com
.
If multiple capture processes at dbs2.example.com
are capturing changes from the dbs1.example.com
source database, then the new capture process uses the same LogMiner data dictionary for dbs1.example.com
as one of the existing capture process. Oracle Streams automatically chooses which LogMiner data dictionary to share with the new capture process.
Note:
During the creation of a downstream capture process, if thefirst_scn
parameter is set to NULL
in the CREATE_CAPTURE
procedure, then the use_database_link
parameter must be set to TRUE
. Otherwise, an error is raised.See Also:
Oracle Database SQL Language Reference for more information about the ALTER
DATABASE
statement
Oracle Data Guard Concepts and Administration for more information registering redo log files
Create the positive rule set for the capture process and add a rule to it:
BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'hr.departments', streams_type => 'capture', streams_name => 'strm04_capture', queue_name => 'strmadmin.streams_queue', include_dml => TRUE, include_ddl => FALSE, include_tagged_lcr => FALSE, source_database => 'dbs1.example.com', inclusion_rule => TRUE); END; /
Running this procedure performs the following actions:
Creates a rule set at dbs2.example.com
for capture process strm04_capture
. The rule set has a system-generated name. The rule set is a positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
Creates a rule that captures DML changes to the hr.departments
table, and adds the rule to the rule set for the capture process. The rule has a system-generated name. The rule is added to the positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
If necessary, complete the steps described in "After Configuring a Capture Process".
To create a capture process that performs downstream capture, you must use the CREATE_CAPTURE
procedure. This section describes creating an archived-log downstream capture process that assigns redo log files explicitly. That is, you must use the DBMS_FILE_TRANSFER
package, FTP, or some other method to transfer redo log files from the source database to the downstream database, and then you must register these redo log files with the downstream capture process manually.
In this example, assume the following:
The source database is dbs1.example.com
and the downstream database is dbs2.example.com
.
The capture process that will be created at dbs2.example.com
uses the streams_queue
owned by strmadmin
.
The capture process will capture data manipulation language (DML) changes made to the hr.departments
table at dbs1.example.com
.
The capture process does not use a database link to the source database for administrative actions.
Complete the following steps:
Complete the tasks in "Preparing to Configure a Capture Process". Because in this example you are transferring and registering archived redo log files explicitly at the downstream database, you do not need to complete the task "Configuring Log File Transfer to a Downstream Capture Database".
In SQL*Plus, connect to the source database dbs1.example.com
as the Oracle Streams administrator.
If you do not use a database link from the downstream database to the source database, then an Oracle Streams administrator must exist at the source database.
See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
If there is no capture process at dbs2.example.com
that captures changes from dbs1.example.com
, then perform a build of the dbs1.example.com
data dictionary in the redo log. This step is optional if a capture process at dbs2.example.com
is already configured to capture changes from the dbs1.example.com
source database.
SET SERVEROUTPUT ON DECLARE scn NUMBER; BEGIN DBMS_CAPTURE_ADM.BUILD( first_scn => scn); DBMS_OUTPUT.PUT_LINE('First SCN Value = ' || scn); END; / First SCN Value = 409391
This procedure displays the valid first SCN value for the capture process that will be created at dbs2.example.com
. Make a note of the SCN value returned because you will use it when you create the capture process at dbs2.example.com
.
If you run this procedure to build the data dictionary in the redo log, then when the capture process is first started at dbs2.example.com
, it will create a LogMiner data dictionary using the data dictionary information in the redo log.
Prepare the hr.departments
table for instantiation:
BEGIN DBMS_CAPTURE_ADM.PREPARE_TABLE_INSTANTIATION( table_name => 'hr.departments', supplemental_logging => 'keys'); END; /
Primary key supplemental logging is required for the hr.departments
table because this example creates a capture processes that captures changes to this table. Specifying keys
for the supplemental_logging
parameter in the PREPARE_TABLE_INSTANTIATION
procedure enables supplemental logging for any primary key, unique key, bitmap index, and foreign key columns in the table.
Determine the current SCN of the source database:
SET SERVEROUTPUT ON SIZE 1000000 DECLARE iscn NUMBER; -- Variable to hold instantiation SCN value BEGIN iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER(); DBMS_OUTPUT.PUT_LINE('Current SCN: ' || iscn); END; /
You can use the returned SCN as the instantiation SCN for destination databases that will apply changes to the hr.departments
table that were captured by the capture process being created. In this example, assume the returned SCN is 1001656
.
Connect to the downstream database dbs2.example.com
as the Oracle Streams administrator.
Run the CREATE_CAPTURE
procedure to create the capture process and specify the value obtained in Step 3 for the first_scn
parameter:
BEGIN DBMS_CAPTURE_ADM.CREATE_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'strm05_capture', rule_set_name => NULL, start_scn => NULL, source_database => 'dbs1.example.com', use_database_link => FALSE, first_scn => 409391, -- Use value from Step 3 logfile_assignment => 'explicit'); END; /
Running this procedure performs the following actions:
Creates a capture process named strm05_capture
at the downstream database dbs2.example.com
. A capture process with the same name must not exist.
Associates the capture process with an existing queue on dbs2.example.com
named streams_queue
and owned by strmadmin
.
Specifies that the source database of the changes that the capture process will capture is dbs1.example.com
.
Specifies that the first SCN for the capture process is 409391
. This value was obtained in Step 3. The first SCN is the lowest SCN for which a capture process can capture changes. Because a first SCN is specified, the capture process creates a new LogMiner data dictionary when it is first started, regardless of whether there are existing LogMiner data dictionaries for the same source database.
Specifies that new redo log files from dbs1.example.com
must be assigned to the capture process explicitly. After a redo log file has been transferred to the computer running the downstream database, you assign the log file to the capture process explicitly using the following statement:
ALTER DATABASE REGISTER LOGICAL LOGFILE file_name FOR capture_process;
Here, file_name
is the name of the redo log file and capture_process
is the name of the capture process that will use the redo log file at the downstream database. You must add redo log files manually if the logfile_assignment
parameter is set to explicit
.
This step does not associate the capture process strm05_capture
with any rule set. A rule set will be created and associated with the capture process in the next step.
See Also:
Oracle Streams Concepts and Administration for more information about SCN values related to a capture process
Oracle Database SQL Language Reference for more information about the ALTER
DATABASE
statement
Oracle Data Guard Concepts and Administration for more information registering redo log files
Create the positive rule set for the capture process and add a rule to it:
BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'hr.departments', streams_type => 'capture', streams_name => 'strm05_capture', queue_name => 'strmadmin.streams_queue', include_dml => TRUE, include_ddl => FALSE, include_tagged_lcr => FALSE, source_database => 'dbs1.example.com', inclusion_rule => TRUE); END; /
Running this procedure performs the following actions:
Creates a rule set at dbs2.example.com
for capture process strm05_capture
. The rule set has a system-generated name. The rule set is a positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
Creates a rule that captures DML changes to the hr.departments
table, and adds the rule to the rule set for the capture process. The rule has a system-generated name. The rule is added to the positive rule set for the capture process because the inclusion_rule
parameter is set to TRUE
.
After the redo log file at the source database dbs1.example.com
that contains the first SCN for the downstream capture process is archived, transfer the archived redo log file to the computer running the downstream database. The BUILD
procedure in Step 3 determined the first SCN for the downstream capture process. If the redo log file is not yet archived, then you can run the ALTER
SYSTEM
SWITCH
LOGFILE
statement on the database to archive it.
You can run the following query at dbs1.example.com
to identify the archived redo log file that contains the first SCN for the downstream capture process:
COLUMN NAME HEADING 'Archived Redo Log|File Name' FORMAT A50 COLUMN FIRST_CHANGE# HEADING 'First SCN' FORMAT 999999999 SELECT NAME, FIRST_CHANGE# FROM V$ARCHIVED_LOG WHERE FIRST_CHANGE# IS NOT NULL AND DICTIONARY_BEGIN = 'YES';
Transfer the archived redo log file with a FIRST_CHANGE#
that matches the first SCN returned in Step 3 to the computer running the downstream capture process.
Connect to the downstream database dbs2.example.com
as an administrative user.
Assign the transferred redo log file to the capture process. For example, if the redo log file is /oracle/logs_from_dbs1/1_10_486574859.dbf
, then issue the following statement:
ALTER DATABASE REGISTER LOGICAL LOGFILE '/oracle/logs_from_dbs1/1_10_486574859.dbf' FOR 'strm05_capture';
If necessary, complete the steps described in "After Configuring a Capture Process".
If you plan to configure propagations and apply processes that process logical change records (LCRs) captured by the new capture process, then perform the configuration in the following order:
Create all of the queues that will be required propagations and apply processes in the replication environment. See "Creating an ANYDATA Queue".
Create all of the propagations that will propagate LCRs captured by the new capture process. See "Creating Oracle Streams Propagations Between ANYDATA Queues".
Create all of the apply processes that will dequeue and process LCRs captured by the new capture process. See Chapter 7, "Configuring Implicit Apply". Configure each apply process to apply captured LCRs.
Instantiate the tables for which the new capture process captures changes at all destination databases. See Chapter 8, "Instantiation and Oracle Streams Replication" for detailed information about instantiation.
Use the START_APPLY
procedure in the DBMS_APPLY_ADM
package to start the apply processes that will process LCRs captured by the new capture process, or see Oracle Database 2 Day + Data Replication and Integration Guide for instructions about starting an apply process using Oracle Enterprise Manager.
Use the START_CAPTURE
procedure in the DBMS_CAPTURE_ADM
package to start the new capture process, or see Oracle Database 2 Day + Data Replication and Integration Guide for instructions about starting a capture process using Oracle Enterprise Manager.
Note:
Other configuration steps might be required for your Oracle Streams environment. For example, some Oracle Streams environments include transformations, apply handlers, and conflict resolution.You can use any of the following procedures to create a synchronous capture:
Both of the procedures in the DBMS_STREAMS_ADM
package create a synchronous capture with the specified name if it does not already exist, create a positive rule set for the synchronous capture if it does not exist, and can add table rules or subset rules to the rule set.
The CREATE_SYNC_CAPTURE
procedure creates a synchronous capture, but does not create a rule set or rules for the synchronous capture. However, the CREATE_SYNC_CAPTURE
procedure enables you to specify an existing rule set to associate with the synchronous capture, and it enables you to specify a capture user other than the default capture user.
The following sections describe configuring a synchronous capture:
Configuring a Synchronous Capture Using the DBMS_STREAMS_ADM Package
Configuring a Synchronous Capture Using the DBMS_CAPTURE_ADM Package
See Also:
Oracle Database 2 Day + Data Replication and Integration Guide for an example that configures a replication environment that uses synchronous capture
The following tasks must be completed before you configure a synchronous capture:
Complete the following tasks in "Tasks to Complete Before Configuring Oracle Streams Replication".
Create ANYDATA
queues to associate with the synchronous capture, if they do not exist. See "Creating an ANYDATA Queue" for instructions. The queue must be a commit-time queue. The examples in this chapter assume that the queue used by synchronous capture is strmadmin.streams_queue
. Create the queue in the same database that will run the synchronous capture.
Create ANYDATA
queues to associate with the propagations that will propagate logical change records (LCRs) captured by the synchronous capture and apply processes that will dequeue and process LCRs captured by the synchronous capture, if they do not exist. See "Creating an ANYDATA Queue" for instructions.
Create all of the propagations that will propagate LCRs captured by the new synchronous capture. See "Creating Oracle Streams Propagations Between ANYDATA Queues".
Create all of the apply processes that will dequeue and process LCRs captured by the new synchronous capture. See "Creating an Apply Process for Persistent LCRs with DBMS_APPLY_ADM". Configure each apply process to apply persistent LCRs by setting the apply_captured
parameter to FALSE
in the DBMS_APPLY_ADM.CREATE_APPLY
procedure. Do not start the apply process until after the instantiation performed in "After Configuring a Synchronous Capture" is complete.
Ensure that the Oracle Streams administrator is granted DBA
role. The Oracle Streams administrator must be granted DBA
role to create a synchronous capture.
When you run the ADD_TABLE_RULES
or ADD_SUBSET_RULES
procedure to create a synchronous capture, set the streams_type
parameter in these procedures to sync_capture
. A rule created by the ADD_TABLE_RULES
procedure instructs the synchronous capture to capture all data manipulation language (DML) changes to the table. A rule created by the ADD_SUBSET_RULES
procedure instructs the synchronous capture to capture a subset of the DML changes to the table.
This example assumes the following:
The source database is dbs1.example.com
.
The synchronous capture that will be created uses the strmadmin.streams_queue
queue.
The synchronous capture that will be created captures the results of DML changes made to the hr.departments
table.
The capture user for the synchronous capture that will be created is the Oracle Streams administrator strmadmin
.
Complete the following steps to create a synchronous capture using the DBMS_STREAMS_ADM
package:
Complete the tasks in "Preparing to Configure a Synchronous Capture".
In SQL*Plus, connect to the dbs1.example.com
database as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
Run the ADD_TABLE_RULES
or ADD_SUBSET_RULES
procedure to create a synchronous capture. For example:
BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'hr.departments', streams_type => 'sync_capture', streams_name => 'sync_capture', queue_name => 'strmadmin.streams_queue'); END; /
This procedure performs the following actions:
Creates a synchronous capture named sync_capture
at the source database.
Enables the synchronous capture. A synchronous capture cannot be disabled.
Associates the synchronous capture with the existing strmadmin.streams_queue
queue.
Creates a positive rule set for the synchronous capture. The rule set has a system-generated name.
Creates a rule that captures DML changes to the hr.departments
table, and adds the rule to the positive rule set for the synchronous capture. The rule has a system-generated name.
Configures the user who runs the procedure as the capture user for the synchronous capture. In this case, this user is strmadmin
.
Prepares the specified table for instantiation by running the DBMS_CAPTURE_ADM.PREPARE_SYNC_INSTANTIATION
function for the table automatically.
Note:
When theADD_TABLE_RULES
or the ADD_SUBSET_RULES
procedure adds rules to a synchronous capture rule set, the procedure must obtain an exclusive lock on the specified table. If there are outstanding transactions on the specified table, then the procedure waits until it can obtain a lock.If necessary, complete the steps described in "After Configuring a Synchronous Capture".
This section contains an example that runs procedures in the DBMS_CAPTURE_ADM
package and DBMS_STREAMS_ADM
package to configure a synchronous capture.
This example assumes the following:
The source database is dbs1.example.com
.
The synchronous capture that will be created uses the strmadmin.streams_queue
queue.
The synchronous capture that will be created uses an existing rule set named sync01_rule_set
in the strmadmin
schema.
The synchronous capture that will be created captures the results of a subset of the DML changes made to the hr.departments
table.
The capture user for the synchronous capture that will be created is hr
. The hr
user must have privileges to enqueue into the streams_queue
.
Complete the following steps to create a synchronous capture using the DBMS_CAPTURE_ADM
package:
Complete the tasks in "Preparing to Configure a Synchronous Capture".
In SQL*Plus, connect to the dbs1.example.com
database as the Oracle Streams administrator.
See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
Create the rule set that will be used by the synchronous capture if it does not exist. In this example, assume that the rule set is strmadmin.sync01_rule_set
. See Oracle Streams Concepts and Administration for instructions.
Run the CREATE_SYNC_CAPTURE
procedure to create a synchronous capture. For example:
BEGIN DBMS_CAPTURE_ADM.CREATE_SYNC_CAPTURE( queue_name => 'strmadmin.streams_queue', capture_name => 'sync01_capture', rule_set_name => 'strmadmin.sync01_rule_set', capture_user => 'hr'); END; /
Running this procedure performs the following actions:
Creates a synchronous capture named sync01_capture
. A synchronous capture with the same name must not exist.
Enables the synchronous capture. A synchronous capture cannot be disabled.
Associates the synchronous capture with the existing queue strmadmin.streams_queue
.
Associates the synchronous capture with the existing rule set strmadmin.sync01_rule_set
.
Configures hr
as the capture user for the synchronous capture.
Run the ADD_TABLE_RULES
or ADD_SUBSET_RULES
procedure to add a rule to the synchronous capture rule set. For example, run the ADD_SUBSET_RULES
procedure to instruct the synchronous capture to capture a subset of the DML changes to the hr.departments
table:
BEGIN DBMS_STREAMS_ADM.ADD_SUBSET_RULES( table_name => 'hr.departments', dml_condition => 'department_id=1700', streams_type => 'sync_capture', streams_name => 'sync01_capture', queue_name => 'strmadmin.streams_queue', include_tagged_lcr => FALSE); END; /
Running this procedure performs the following actions:
Adds subset rules to the rule set for the synchronous capture named sync01_capture
at the source database dbs1.example.com
. The subset rules instruct the synchronous capture to capture changes to rows with department_id
equal to 1700
. The synchronous capture does not capture changes to other rows in the table.
Prepares the hr.departments
table for instantiation by running the DBMS_CAPTURE_ADM.PREPARE_SYNC_INSTANTIATION
function for the table automatically.
Specifies that the synchronous capture captures a change only if the session that makes the change has a NULL
tag, because the include_tagged_lcr
parameter is set to FALSE
. This behavior is accomplished through the system-created rules for the synchronous capture.
Note:
When theCREATE_SYNC_CAPTURE
procedure creates a synchronous capture, the procedure must obtain an exclusive lock on each table for which it will capture changes. The rules in the specified rule set for the synchronous capture determine these tables. Similarly, when the ADD_TABLE_RULES
or the ADD_SUBSET_RULES
procedure adds rules to a synchronous capture rule set, the procedure must obtain an exclusive lock on the specified table. In these cases, if there are outstanding transactions on a table for which the synchronous capture will capture changes, then the procedure waits until it can obtain a lock.If necessary, complete the steps described in "After Configuring a Synchronous Capture".
If you configured propagations and apply processes that process logical change records (LCRs captured) by the new synchronous capture, then complete the following steps:
Instantiate the tables for which the new synchronous capture captures changes at all destination databases. See Chapter 8, "Instantiation and Oracle Streams Replication" for detailed information about instantiation.
Use the START_APPLY
procedure in the DBMS_APPLY_ADM
package to start the apply processes that will process LCRs captured by the new synchronous capture, or see Oracle Database 2 Day + Data Replication and Integration Guide for instructions about starting an apply process using Oracle Enterprise Manager.
Note:
Other configuration steps might be required for your Oracle Streams environment. For example, some Oracle Streams environments include transformations, apply handlers, and conflict resolution.