Step by step example on setting up streams

652 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
652
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
49
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Step by step example on setting up streams

  1. 1. AnarGodjaev http://anargodjaev.wordpress.com/ Step by Step example on settingup Streams - Oracle 11g Step 1 Create Users & Setup Privileges SQL>CREATE USER ANAR IDENTIFIED BY ANAR; SQL>GRANT CONNECT, RESOURCE, DBA TO ANAR; SQL>GRANT SELECT_CATALOG_ROLE TO ANAR; SQL>GRANT UNLIMITED TABLESPACE TO ANAR; SQL>EXECUTE DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(GRANTEE => 'ANAR'); Step 2 Create database links at source and target databases connectANAR/ANAR@AZKKTST1 CREATE DATABASE LINK AZKKTST2 CONNECT TO ANAR IDENTIFIED BY ANAR USING 'AZKKTST2'; connectANAR/ANAR@AZKKTST2 CREATE DATABASE LINK AZKKTST1 CONNECT TO ANAR IDENTIFIED BY ANAR USING 'AZKKTST1'; Step 3 Create the queue at AZKKTST1/AZKKTST2 - Source Database connectANAR/ANAR@AZKKTST1 BEGIN DBMS_STREAMS_ADM.SET_UP_QUEUE ( QUEUE_TABLE => 'C1_STREAM_Q1_QT', QUEUE_NAME => 'C1_STREAM_Q1', QUEUE_USER => 'ANAR'); END; / Create the queue at AZKKTST2 (Target) ## connectANAR/ANAR@AZKKTST2 BEGIN DBMS_STREAMS_ADM.SET_UP_QUEUE ( QUEUE_TABLE => 'A1_STREAM_Q1_QT', QUEUE_NAME => 'A1_STREAM_Q1', QUEUE_USER => 'ANAR'); END; / Step 4 Create capture at source Connect to AZKKTST1...
  2. 2. AnarGodjaev http://anargodjaev.wordpress.com/ connectANAR/ANAR@AZKKTST1 BEGIN DBMS_STREAMS_ADM.ADD_SCHEMA_RULES( schema_name =>'OC_UNW', streams_type =>'CAPTURE', streams_name =>'C1_STREAM', queue_name =>'ANAR.C1_STREAM_Q1', include_dml =>TRUE, include_ddl =>TRUE, source_database =>'AZKKTST1'); END; / Step 5 Create apply process at target connectANAR/ANAR@AZKKTST2 BEGIN DBMS_STREAMS_ADM.ADD_SCHEMA_RULES ( SCHEMA_NAME => 'OC_UNW', STREAMS_TYPE => 'APPLY', STREAMS_NAME => 'A1_STREAM', QUEUE_NAME => 'ANAR.A1_STREAM_Q1', INCLUDE_DML => TRUE, INCLUDE_DDL => TRUE, SOURCE_DATABASE => 'AZKKTST1'); END; / BEGIN DBMS_APPLY_ADM.SET_PARAMETER( apply_name => 'A1_STREAM', parameter => 'disable_on_error', value => 'n'); END; / Step 6 Create propagation at source connectANAR/ANAR@AZKKTST1 BEGIN DBMS_STREAMS_ADM.ADD_SCHEMA_PROPAGATION_RULES ( SCHEMA_NAME => 'OC_UNW', STREAMS_NAME => 'P1_STREAM', SOURCE_QUEUE_NAME => 'ANAR.C1_STREAM_Q1', DESTINATION_QUEUE_NAME => 'ANAR.A1_STREAM_Q1@AZKKTST2', INCLUDE_DML => TRUE, INCLUDE_DDL => TRUE); END; / Step 7 Instantiation at AZKKTST2
  3. 3. AnarGodjaev http://anargodjaev.wordpress.com/ At source AZKKTST1... SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL; expdpANAR/ANAR@AZKKTST1 SCHEMAS=OC_UNW DIRECTORY=expadmin DUMPFILE=OC_UNW.dmp logfile=OC_UNW.log PARALLEL=4 FLASHBACK_SCN=<scn> At Target AZKKTST2... impdpANAR/ANAR@AZKKTST2 SCHEMAS=OC_UNW DIRECTORY=expadmin DUMPFILE=OC_UNW.dmp logfile=OC_UNW.log PARALLEL=4 Check if schema instantiation is working fine.. select * from DBA_APPLY_INSTANTIATED_SCHEMAS; connectANAR/ANAR@AZKKTST2 declare v_scn number; begin v_scn := 943015; dbms_output.put_line('Scn : ' || v_scn); dbms_apply_adm.set_schema_instantiation_scn( source_schema_name => 'OC_UNW', source_database_name => 'AZKKTST1', instantiation_scn =>v_scn, recursive => true); end; / Step 8 At target start apply connectANAR/ANAR@AZKKTST2 execdbms_apply_adm.start_apply('A1_STREAM'); Step 9 At source start capture connectANAR/ANAR@AZKKTST1 exec DBMS_CAPTURE_ADM.START_CAPTURE('C1_STREAM');

×