DataSync: Data Replication (SCOTT.EMP) between Oracle databases

Links: http://www.dbatools.net/mytools/datasync-data-replication.html

    I want to introduce a new utility for data replication solution based on materialized view log or user defined triggers, I named it as DataSync, suppose that we want to replicate table (SCOTT.EMP)'s data from DB1 to DB2 with low latency (less than 5s). Take a look at the command line help first.

DataSync: Oracle Data Replication Utility, Release 2.0.1
(c) Copyright Lou Fangxin (AnySQL.net) 2010, all rights reserved.

Usage: datasync keyword=value [,keyword=value,...]

Valid Keywords:
  user    = username/password@tnsname for source and target.
  user1  = username/password@tnsname for source database.
  user2  = username/password@tnsname for target database.
* wait    = wait time in microsecond after each array.
  array  = array fetch size
  long    = maximum size for long, long raw, CLOB, BLOB columns.
* crypt  = encrypt the connection info only, no data copy (YES/NO).
  parfile = read command option from parameter file
  config  = config files.
* dbid    = target database flag column of log table.
* dblist  = all target database flag columns of log table.
* init    = fix message out of sync before replication(YES).
  log    = log file name for screen messages.

Notes:
  datasync user1=scott/tiger user2=scott/tiger config=scott.cfg init=yes

Config:
  Source # Primary Key # Log Table # Target # Conflict # Filler # Where

    Then we will start to do the replication of table (SCOTT.EMP), it's very simple.

    1, Create Materilaized View Log on SCOTT.EMP

CREATE MATERILIZED VIEW LOG ON EMP WITH SEQUENCE, PRIMARY KEY;
CREATE INDEX MLOG$_EMP_IX1 ON MLOG$_EMP (SEQUENCE$$);

    2, Prepare a configuration file for replication, one table per line.

D:\>type scott.cfg
EMP  #EMPNO  #MLOG$_EMP  #EMP

    3, Data initialize between tow databases with DataCopy

datacopy user1=scott/tiger@db1 user2=scott/tiger@db2 table=emp

    4, start data replication daemon with init mode

datasync user1=scott/tiger@db1 user2=scott/tiger@db2 config=scott.cfg

    5, Make DML changes on source database, changes will be replicated.

update emp set comm = nvl(comm,0) + 200;

    Now you have a very light replication tools, you can use it to make read database for you application.

Post a comment

Remember Me?

« Previous | Main | Next »

Powered by
Movable Type 5.01