1.將ogg安裝包傳至服務器目錄,以oracle用戶解壓(例:ORACLE_BASE目錄下)
2.增加Oracle系統環境變量 LD_LIBRARY_PATH=/opt/app/oracle/product/11.2.0/dbhome_1/lib
ogg在運行時會調用oracle相關庫文件
3.在源端與目標端創建同步用戶,該用戶必須能夠訪問源數據庫和目標數據庫用戶下面的所有數據
create user oggadmin identified by oggadmin;
grant dba to oggadmin;
SQL> alter database add supplemental log data (all) columns;
Database altered.
SQL>
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (DG1) 1> create subdirs
Creating subdirectories under current directory /opt/app/oracle/ogg
Parameter files /opt/app/oracle/ogg/dirprm: already exists
Report files /opt/app/oracle/ogg/dirrpt: created
Checkpoint files /opt/app/oracle/ogg/dirchk: created
Process status files /opt/app/oracle/ogg/dirpcs: created
SQL script files /opt/app/oracle/ogg/dirsql: created
Database definitions files /opt/app/oracle/ogg/dirdef: created
Extract data files /opt/app/oracle/ogg/dirdat: created
Temporary files /opt/app/oracle/ogg/dirtmp: created
Stdout files /opt/app/oracle/ogg/dirout: created
GGSCI (DG1) 2> edit params mgr
GGSCI (DG1) 3> vi .global
ERROR: Invalid command.
GGSCI (DG1) 4> edit params GLOBALS
checkpointtable oggadmin.ggchkpt
GGSCI (DG1) 5> exit
[oracle@DG1 ogg]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (DG1) 1> start manager
Manager started.
GGSCI (DG1) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
GGSCI (DG1) 3> start manager
Manager started.
GGSCI (DG1) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
GGSCI (DG1) 5> dblogin userid oggadmin,password oggadmin
Successfully logged into database.
GGSCI (DG1) 6> add checkpointtable
ERROR: Missing checkpoint table specification.
GGSCI (DG1) 7> edit param GLOBAL
GGSCI (DG1) 8> edit params globals
GGSCI (DG1) 9> add checkpointtable oggadmin.ggchkpt
Successfully created checkpoint table oggadmin.ggchkpt.
GGSCI (DG1) 11> edit params sour1
GGSCI (DG1) 12> view param sour1
extract sour1
setenv (ORACLE_SID=shanghai)
userid oggadmin,password oggadmin
tranlogoptions excludeuser oggadmin
RMTHOST 10.61.2.25,MGRPORT 7809
RMTTRAIL ./dirdat/sa
table scott.t1;
GGSCI (DG1) 35> add extract sour1,tranlog ,begin now
EXTRACT added.
GGSCI (DG1) 36> add rmttrail ./dirdat/sa,extract sour1,megabytes 50
RMTTRAIL added.
GGSCI (DG1) 37> start extract sour1
Sending START request to MANAGER ...
EXTRACT SOUR1 starting
GGSCI (DG1) 38> info sour1
EXTRACT SOUR1 Last Started 2013-08-29 15:28 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:01:54 ago)
Log Read Checkpoint Oracle Redo Logs
2013-08-29 15:26:41 Seqno 211, RBA 9636352
SCN 0.0 (0)
GGSCI (DG1) 39> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING SOUR1 00:00:00 00:01:58
Target:
GGSCI (eagle) 6> edit params GLOBALS
ggschema oggadmin
checkpointtable oggadmin.ggchkpt
GGSCI (eagle) 2> add replicat targ1,exttrail ./dirdat/sa,checkpointtable oggadmin.ggchkpt
REPLICAT added.
GGSCI (eagle) 9> edit params targ1
replicat targ1
assumetargetdefs
SETENV(ORACLE_SID=orcl)
USERID oggadmin,password oggadmin
map scott.t1 ,target scott.t1;
GGSCI (eagle) 17> start REPLICAT targ1
Sending START request to MANAGER ...
REPLICAT TARG1 starting
GGSCI (eagle) 18> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT ABENDED RSCOTT 00:00:00 118:21:16
REPLICAT RUNNING TARG1 00:00:00 00:21:37
GGSCI (eagle) 13> edit params mgr
port 7809
dynamicportlist 7840-7915
userid oggadmin,password oggadmin
purgeoldextracts ./dirdat/sa,usecheckpoints,minkeepdays 3
將目標端作爲源:
GGSCI (eagle) 25> edit params sour2
extract sour2
setenv (ORACLE_SID=orcl)
userid oggadmin,password oggadmin
tranlogoptions excludeuser oggadmin
RMTHOST 10.61.13.41,MGRPORT 7809
RMTTRAIL ./dirdat/sa
table scott.t1;
~
~
GGSCI (eagle) 29> add rmttrail ./dirdat/sa,extract sour2,megabytes 50
RMTTRAIL added.
GGSCI (eagle) 30> start extract sour2
Sending START request to MANAGER ...
EXTRACT SOUR2 starting
GGSCI (eagle) 31> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING SOUR2 00:00:00 00:01:09
REPLICAT ABENDED RSCOTT 00:00:00 118:39:51
REPLICAT RUNNING TARG1 00:00:00 00:00:06
GGSCI (eagle) 32>
源作爲目標端:
GGSCI (DG1) 8> add replicat targ2,exttrail ./dirdat/sa,checkpointtable oggadmin.ggchkpt
REPLICAT added.
GGSCI (DG1) 9> edit params targ2
replicat targ2
assumetargetdefs
SETENV(ORACLE_SID=shanghai)
USERID oggadmin,password oggadmin
map scott.t1 ,target scott.t1;
~
GGSCI (DG1) 28> start replicat targ2
Sending START request to MANAGER ...
REPLICAT TARG2 starting
GGSCI (DG1) 29> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING SOUR1 00:00:00 00:00:04
REPLICAT RUNNING TARG2 00:00:00 00:00:07