Oracle Multi-Directional Data ReplicationMay 11, 2006 In part one of this series, we illustrated the procedures for setting up bi-directional data replication and conflict resolution between two databases using Oracle 10g Streams. In the second half of this series, we will provide the steps to add a new source site into our existing bi-directional replicated environment. At the end of the set up, we will have a three-way directional replicated environment. Changes originate from one database, are propagated to the rest of the databases, thus keeping all sites synchronized. Adding a New Source SiteAn overview of the current Oracle bi-directional Streams environment:
An overview of the Oracle multi-directional Streams environment:
Step 1: Configure archive log modeArchived redo logs are required by the capture process to extract changes. Verify dcdb is in archive log mode and configure your log archive destination or flash recovery area. Step 2: Modify initialization parameters
Step 3: Set up tnsnames.oraAdd the TNS entries on trout1, trout3 and trout4.
DCDB.WORLD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = trout1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dcdb)
)
)
LADB.WORLD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = trout3)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ladb)
)
)
SFDB.WORLD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = trout4)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sfdb)
)
)
Step 4: Create tablespacesCreate the tablespaces for the application schema and Streams administrator in dcdb. create tablespace appsts datafile '/u02/oradata/dcdb/appsts01.dbf' size 100M; create tablespace streamsts datafile '/u02/oradata/dcdb/streamsts01.dbf' size 100M; Step 5: Create Streams administratorCreate the Streams administrator in dcdb. create user strmadmin identified by strmadmin default tablespace streamsts temporary tablespace temp;
grant dba,select_catalog_role to strmadmin;
exec dbms_streams_auth.grant_admin_privilege('strmadmin',true);
Step 6: Create application schemaCreate the application schema in dcdb. create user apps identified by apps default tablespace appsts temporary tablespace temp; grant connect,resource to apps; grant select on v_$database to apps; Step 7: Create database linkAs the Streams administrator, create the following private database links in each database. On dcdbcreate database link ladb.world connect to strmadmin identified by strmadmin using 'ladb.world'; create database link sfdb.world connect to strmadmin identified by strmadmin using 'sfdb.world'; On ladbcreate database link dcdb.world connect to strmadmin identified by strmadmin using 'dcdb.world'; On sfdbcreate database link dcdb.world connect to strmadmin identified by strmadmin using 'dcdb.world'; Step 8: Create Streams queuesAs the Streams administrator, create the capture and apply queues in dcdb. begin dbms_streams_adm.set_up_queue( queue_table => 'apply_dcqtab', queue_name => 'apply_dcq', queue_user => 'strmadmin'); end; / begin dbms_streams_adm.set_up_queue( queue_table => 'capture_dcqtab', queue_name => 'capture_dcq', queue_user => 'strmadmin'); end; / Step 9: Configure capture, apply and propagation processesAs the Streams administrator on each source database, execute: On ladbbegin dbms_streams_adm.add_schema_propagation_rules ( schema_name => 'apps', streams_name => 'prop_ladb_to_dcdb', source_queue_name => 'capture_laq', destination_queue_name => 'apply_dcq@dcdb.world', include_dml => true, include_ddl => true, source_database => 'ladb.world'); end; / begin dbms_streams_adm.add_schema_rules ( schema_name => 'apps', streams_type => 'apply', streams_name => 'apply_src_dcdb', queue_name => 'apply_laq', include_dml => true, include_ddl => true, source_database => 'dcdb.world'); end; / On sfdbbegin dbms_streams_adm.add_schema_propagation_rules ( schema_name => 'apps', streams_name => 'prop_sfdb_to_dcdb', source_queue_name => 'capture_sfq', destination_queue_name => 'apply_dcq@dcdb.world', include_dml => true, include_ddl => true, source_database => 'sfdb.world'); end; / begin dbms_streams_adm.add_schema_rules ( schema_name => 'apps', streams_type => 'apply', streams_name => 'apply_src_dcdb', queue_name => 'apply_sfq', include_dml => true, include_ddl => true, source_database => 'dcdb.world'); end; / On dcdbbegin dbms_streams_adm.add_schema_rules ( schema_name => 'apps', streams_type => 'capture', streams_name => 'capture_dcstrm', queue_name => 'capture_dcq', include_dml => true, include_ddl => true, inclusion_rule => true); end; / begin dbms_streams_adm.add_schema_propagation_rules ( schema_name => 'apps', streams_name => 'prop_dcdb_to_ladb', source_queue_name => 'capture_dcq', destination_queue_name => 'apply_laq@ladb.world', include_dml => true, include_ddl => true, source_database => 'dcdb.world'); end; / begin dbms_streams_adm.add_schema_propagation_rules ( schema_name => 'apps', streams_name => 'prop_dcdb_to_sfdb', source_queue_name => 'capture_dcq', destination_queue_name => 'apply_sfq@sfdb.world', include_dml => true, include_ddl => true, source_database => 'dcdb.world'); end; / begin dbms_streams_adm.add_schema_rules ( schema_name => 'apps', streams_type => 'apply', streams_name => 'apply_src_ladb', queue_name => 'apply_dcq', include_dml => true, include_ddl => true, source_database => 'ladb.world'); end; / begin dbms_streams_adm.add_schema_rules ( schema_name => 'apps', streams_type => 'apply', streams_name => 'apply_src_sfdb', queue_name => 'apply_dcq', include_dml => true, include_ddl => true, source_database => 'sfdb.world'); end; / Step 10: Prepare schema instantiationAs the Streams administrator, prepare for instantiation all current and future schema objects in ladb and sfdb. The lowest SCN of each object in the apps schema is recorded for instantiation. On ladbexec dbms_capture_adm.prepare_schema_instantiation(schema_name =>'apps'); On sfdbexec dbms_capture_adm.prepare_schema_instantiation(schema_name =>'apps'); |