Configuring Advanced Replication

356 views
294 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
356
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Configuring Advanced Replication

  1. 1. Configuring Advanced Replication Julian Dyke Independent Consultant Web Version - July 2009 juliandyke.com © 2009 Julian Dyke
  2. 2. Introduction <ul><li>This presentation describes a basic Advanced Replication multi-master configuration </li></ul><ul><li>The configuration is between two databases DB1 and DB2 running on servers node1 and node2 respectively </li></ul><ul><li>One table called TEAM from the GP schema is replicated </li></ul><ul><li>The sample configuration was developed in Oracle 10.2.0.4 on Linux 32-bit </li></ul>
  3. 3. Advanced Replication Replicated Objects <ul><li>Create a user </li></ul>CREATE USER gp IDENTIFIED BY gp; GRANT DBA TO gp; <ul><li>As the GP user create and populate a table to be replicated </li></ul>CREATE TABLE team ( team_code VARCHAR2(3), team_name VARCHAR2(30), country_code VARCHAR2(3) ); ALTER TABLE team ADD CONSTRAINT team_pk PRIMARY KEY (team_code); INSERT INTO team VALUES ('MCL','McLaren','GBR'); INSERT INTO team VALUES ('FER','Ferrari','FER'); COMMIT; <ul><li>Note - table MUST have primary key constraint </li></ul>
  4. 4. Advanced Replication Replication Administrator <ul><li>On each node as SYS (SYSDBA) </li></ul><ul><ul><li>create a user called REPADMIN </li></ul></ul>CREATE USER repadmin IDENTIFIED BY repadmin; <ul><ul><li>grant privileges to REPADMIN to create and manage the replicated environment </li></ul></ul>BEGIN dbms_repcat_admin.grant_admin_any_schema (username=> 'REPADMIN'); END; /
  5. 5. Advanced Replication Register Propagator <ul><li>On each node as SYS (SYSDBA) </li></ul><ul><ul><li>register REPADMIN as a propagator </li></ul></ul>BEGIN dbms_defer_sys.register_propagator (username => 'REPADMIN'); END; / <ul><li>The propagator is responsible for propagating the deferred transaction queue to other master sites. </li></ul>
  6. 6. Advanced Replication Register Receiver <ul><li>On each node as SYS (SYSDBA) </li></ul><ul><ul><li>register REPADMIN as a receiver </li></ul></ul>BEGIN dbms_repcat_admin.register_user_repgroup ( username => 'REPADMIN', privilege_type => 'RECEIVER', list_of_gnames => NULL ); END; / <ul><li>The receiver receives the propagated deferred transactions sent by the propagator from other master sites. </li></ul>
  7. 7. Advanced Replication Schedule Purge <ul><li>On each node as REPADMIN </li></ul><ul><ul><li>schedule an hourly purge of the deferred transactions queue </li></ul></ul>BEGIN dbms_defer_sys.schedule_purge ( next_date => SYSDATE, interval => 'SYSDATE + 1/24', delay_seconds => 0 ); END; / <ul><li>Successfully completed deferred transactions should be purged to reduce the size of the deferred transactions queue </li></ul>
  8. 8. Advanced Replication Configure Network <ul><li>On each node add network services to </li></ul><ul><ul><li>$ORACLE_HOME/network/admin/tnsnames.ora </li></ul></ul>DB1.JULIANDYKE.COM= (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP)(HOST=node1)(PORT=1521)) (CONNECT_DATA = (SID=DB1)) ) DB2.JULIANDYKE.COM= (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP)(HOST=node2)(PORT=1521)) (CONNECT_DATA = (SID=DB2)) )
  9. 9. Advanced Replication Database Links <ul><li>In DB1 </li></ul><ul><ul><li>As SYS (SYSDBA) create public database link e.g. </li></ul></ul>CREATE PUBLIC DATABASE LINK db2.juliandyke.com USING 'db2.juliandyke.com'; <ul><ul><li>As REPADMIN create private database link e.g. </li></ul></ul>CREATE DATABASE LINK db2.juliandyke.com CONNECT TO repadmin IDENTIFIED BY repadmin; <ul><li>In DB2 </li></ul><ul><ul><li>As SYS (SYSDBA) create public database link e.g. </li></ul></ul>CREATE PUBLIC DATABASE LINK db1.juliandyke.com USING 'db1.juliandyke.com'; <ul><ul><li>As REPADMIN create private database link e.g. </li></ul></ul>CREATE DATABASE LINK db1.juliandyke.com CONNECT TO repadmin IDENTIFIED BY repadmin;
  10. 10. Advanced Replication Scheduled Links <ul><li>In each database as REPADMIN </li></ul><ul><ul><li>Define a schedule for each database link </li></ul></ul><ul><ul><li>e.g. in DB1 </li></ul></ul>BEGIN dbms_defer_sys.schedule_push ( destination => 'db2.juliandyke.com', interval => 'SYSDATE + (1/144)', next_date => SYSDATE, parallelism => 1, execution_seconds => 1500, delay_seconds => 120 ); END; / <ul><li>In DB2 set the destination to db1.juliandyke.com </li></ul>
  11. 11. Advanced Replication Replication Group <ul><li>In DB1 only as REPADMIN </li></ul><ul><ul><li>Create a replication group called REPGROUP1 </li></ul></ul>BEGIN dbms_repcat.create_master_repgroup (gname => 'REPGROUP1'); END; /
  12. 12. Advanced Replication Replication Objects <ul><li>In DB1 only as REPADMIN </li></ul><ul><ul><li>Create a replication object for GP.TEAM table </li></ul></ul>BEGIN dbms_repcat.create_master_repobject ( gname => 'REPGROUP1', type => 'TABLE', sname => 'GP', oname => 'TEAM', use_existing_object => TRUE, copy_rows => TRUE ); END; /
  13. 13. Advanced Replication Add Master Databases <ul><li>In DB1 only as REPADMIN </li></ul><ul><ul><li>Add DB2 as a second master database in REPGROUP1 </li></ul></ul>BEGIN dbms_repcat.add_master_database ( gname => 'REPGROUP1', master => 'db2.juliandyke.com', use_existing_objects => TRUE, copy_rows => TRUE, propagation_mode => 'ASYNCHRONOUS' ); END; / <ul><li>Check new master has been added using: </li></ul>SELECT dblink FROM dba_repsites WHERE gname = 'REPGROUP1';
  14. 14. Advanced Replication Generate Replication Support <ul><li>In DB1 only as REPADMIN </li></ul><ul><ul><li>Generate replication support for GP.TEAM </li></ul></ul>BEGIN dbms_repcat.generate_replication_support ( sname => 'GP', oname => 'TEAM', type => 'TABLE', min_communication => TRUE ); END; /
  15. 15. Advanced Replication Start Replication <ul><li>In DB1 only as REPADMIN </li></ul><ul><ul><li>Resume replication for REPGROUP1 </li></ul></ul>BEGIN dbms_repcat.resume_master_activity (gname => 'REPGROUP1'); END; /
  16. 16. Thank you for your interest

×