dongxujian 发表于 2014-5-15 18:22:45

Oracle 9.2.0.8 RHEL 4U GoldenGate V11.1.1.1.2 cascade 级联 DML 复制实践


一概述:

三台主机分别安装数据库ORACLE 9.2.6 升级至9.2.0.8.0,gg1为源端,gg2为中间库,.gg3 为目标端,
gg1上配置一个抽取,一个投递,投递进程关联gg2的trail
gg2上分别配置一个复制接受gg1,一个抽取进程,一个投递进程,投递进程关联gg3的trail文件
gg3上配置一个复制进程,gg1,gg2 端要求开启归档,gg3主机可选是否开启归档
每台虚拟机上均要配置MGR管理进程
此次测试的三台虚拟机是克隆的一台虚拟机的快照,克隆后调整每台虚拟机的IP地址,注意还要调整数据库的tnsnames.ora及listener.ora文件
的主机名或ip地址,主机名及ip调整参考ip地址规划

中间库配置了检查点表,源端机目标端未配置检查点表ggs,ckpt




1.1 ip 规划:


$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
192.168.1.207   gg1.abc.com   gg1
192.168.1.208   gg2.abc.com   gg2
192.168.1.209   gg3.abc.com   gg3

1.2 操作系统版本:


# uname -rm
2.6.9-78.EL x86_64
# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 7)


1.3 数据库版本:




$ sqlplus /nolog

SQL*Plus: Release 9.2.0.8.0 - Production on Mon May 12 01:26:04 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.

SQL> connect /as sysdba
Connected.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE    9.2.0.8.0       Production
TNS for Linux: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production

$ ggsci -v

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.


备注:oracle 9i 数据库的安装及升级参考其他相关文档,此处不做详细说明

1.4 goldengate 软件版本:

压缩包:V28957-01
goldengate v11.1.1.1.2
ggs_Linux_x64_ora9i_64bit.tar




二 goldengate 软件安装


以下操作无特别说明均是在三台虚拟机上做同样的操作


2.1创建安装用户

此次测试均采用 oracle 用户安装,为创建单独的goldengate软件安装用户

调整oracle 用户的 .bash_profile 文件添加以下内容


调整前:


$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
      . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

#export PATH
# Oracle 9i
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2.0; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$ORACLE_HOME/bin:$PATH; export PATH
ORACLE_OWNER=oracle; export ORACLE_OWNER
ORACLE_SID=orcl; export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib; export CLASSPATH
LD_ASSUME_KERNEL=2.4.19; export LD_ASSUME_KERNEL
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
#unset USERNAME



调整后:


设置环境变量主要为下面两行的调整:

export PATH=$PATH:$ORACLE_HOME/bin:/home/oracle/ggs
export LD_LIBRARY_PATH=/home/oracle/ggs:$ORACLE_HOME/lib

调整后的.bash_profile
$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
      . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

#export PATH
# Oracle 9i
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/9.2.0; export ORACLE_HOME
GGHOME=/home/oracle/ggs;export GGHOME
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$ORACLE_HOME/bin:$PATH:/home/oracle/ggs; export PATH
ORACLE_OWNER=oracle; export ORACLE_OWNER
ORACLE_SID=orcl; export ORACLE_SID
LD_LIBRARY_PATH=/home/oracle/ggs:$ORACLE_HOME/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib; export CLASSPATH
LD_ASSUME_KERNEL=2.4.19; export LD_ASSUME_KERNEL
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
#unset USERNAME


2.2 创建goldengate 软件安装目录


$ mkdir ggs
$ pwd
/home/oracle
$ cd ggs
$ pwd
/home/oracle/ggs


2.3 上传goldengate软件,安装goldengate软件

关闭iptables服务:

# chkconfig --list | grep iptables
iptables      0:off   1:off   2:on    3:on    4:on    5:on    6:off
# service iptables status
Firewall is stopped.
# chkconfig iptables off
# chkconfig --list | grep sendmail
sendmail      0:off   1:off   2:off   3:off   4:off   5:off   6:off

防止相应端口被禁止,熟悉的话也可配置开放相应端口

关闭sendmail服务:

# service sendmail status
sendmail is stopped
# chkconfig sendmail off

sendmai 启动时间较长,禁止启动


# pwd
/root
# ls -l
total 266848
-rw-r--r--1 root root      3061 Sep 252012 anaconda-ks.cfg
drwxr-xr-x2 root root      4096 Sep 252012 Desktop
-rwxrwxrwx1 root root 272834560 Oct42011 ggs_Linux_x64_ora9i_64bit.tar
-rw-r--r--1 root root   72353 Sep 252012 install.log
-rw-r--r--1 root root   44487 Sep 252012 install.log.syslog
# chmod 777 ggs_Linux_x64_ora9i_64bit.tar
# mv ggs_Linux_x64_ora9i_64bit.tar /home/oracle/ggs/
# su - oracle
$ cd /home/oracle/ggs
$ ls -l
total 266708
-rwxrwxrwx1 root root 272834560 Oct42011 ggs_Linux_x64_ora9i_64bit.tar
$ tar xf ggs_Linux_x64_ora9i_64bit.tar
$ pwd
/home/oracle/ggs
$ ls -l
total 515316
-r--r--r--1 oracle oinstall       426 Oct 152010 bcpfmt.tpl
-r--r--r--1 oracle oinstall      1725 Oct 152010 bcrypt.txt
drwxr-xr-x2 oracle oinstall      4096 Oct52011 cfg
-r--r--r--1 oracle oinstall       739 Oct 152010 chkpt_ora_create.sql
-rwxr-xr-x1 oracle oinstall   8196774 Oct52011 cobgen
-rwxr-xr-x1 oracle oinstall   8138288 Oct52011 convchk
-r--r--r--1 oracle oinstall       159 Oct 152010 db2cntl.tpl
-r--r--r--1 oracle oinstall      3334 Oct 152010 ddl_access.tpl
-r--r--r--1 oracle oinstall      1059 Oct 152010 ddl_cleartrace.sql
-rwxr-xr-x1 oracle oinstall   8277118 Oct52011 ddlcob
-r--r--r--1 oracle oinstall      3502 Oct 152010 ddl_db2_os390.tpl
-r--r--r--1 oracle oinstall      3017 Oct 152010 ddl_db2.tpl
-r--r--r--1 oracle oinstall      4189 Oct 152010 ddl_ddl2file.sql
-r--r--r--1 oracle oinstall       746 Oct 152010 ddl_disable.sql
。。。。。。。输出较多部分省略。。。。。。。。。。。。


2.4配置mgr(相应的管理进程端口均为7809),创建goldengate相关目录:

$ cd $GGHOME
$ pwd
/home/oracle/ggs
$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg1.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   STOPPED                                          


GGSCI (gg1.abc.com) 2> create subdirs

Creating subdirectories under current directory /home/oracle/ggs

Parameter files                /home/oracle/ggs/dirprm: created
Report files                   /home/oracle/ggs/dirrpt: created
Checkpoint files               /home/oracle/ggs/dirchk: created
Process status files         /home/oracle/ggs/dirpcs: created
SQL script files               /home/oracle/ggs/dirsql: created
Database definitions files   /home/oracle/ggs/dirdef: created
Extract data files             /home/oracle/ggs/dirdat: created
Temporary files                /home/oracle/ggs/dirtmp: created
Veridata files               /home/oracle/ggs/dirver: created
Veridata Lock files            /home/oracle/ggs/dirver/lock: created
Veridata Out-Of-Sync files   /home/oracle/ggs/dirver/oos: created
Veridata Out-Of-Sync XML files /home/oracle/ggs/dirver/oosxml: created
Veridata Parameter files       /home/oracle/ggs/dirver/params: created
Veridata Report files          /home/oracle/ggs/dirver/report: created
Veridata Status files          /home/oracle/ggs/dirver/status: created
Veridata Trace files         /home/oracle/ggs/dirver/trace: created
Stdout files                   /home/oracle/ggs/dirout: created


GGSCI (gg1.abc.com) 3> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   STOPPED                                          


GGSCI (gg1.abc.com) 4> edit params mgr


port 7809
~

"dirprm/mgr.prm" 1L, 10C written


GGSCI (gg1.abc.com) 5> view report mgr
ERROR: REPORT file MGR does not exist.


GGSCI (gg1.abc.com) 6> view params mgr

port 7809


GGSCI (gg1.abc.com) 7> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   STOPPED                                          


GGSCI (gg1.abc.com) 8> start mgr

Manager started.


GGSCI (gg1.abc.com) 9> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          


确认gg1,gg2,gg3三台虚拟机上状态均同上
---2.1至2.4操作均在三台虚拟机上操作




2.5 源端(gg1,gg2)及目标端(gg3)数据库参数调整


源端(gg1,gg2)配置
.oracle数据库设置
SQL> create user ggs identified by ggs account unlock;
SQL> grant dba to ggs
【如果对权限有要求,如没要求,一般就给dba权限,详细权限为:
SQL> GRANT create table to ggs;
SQL> GRANT CONNECT TO ggs;
SQL> GRANT ALTER ANY TABLE TO ggs;
SQL> GRANT ALTER SESSION TO ggs;
SQL> GRANT CREATE SESSION TO ggs;
SQL> GRANT FLASHBACK ANY TABLE TO ggs;
SQL> GRANT SELECT ANY DICTIONARY TO ggs;
SQL> GRANT SELECT ANY TABLE TO ggs;
SQL> GRANT RESOURCE” TO ggs;
SQL> GRANT DELETE ANY TABLE TO ggs;
SQL> GRANT INSERT ANY TABLE TO ggs;
SQL> GRANT UPDATE ANY TABLE TO ggs;
SQL> GRANT RESTRICTED SESSION TO ggs; 】
将数据库设置为归档模式:
SQL> alter database archivelog(在mount 状态下执行)
修改归档模式参数
SQL> archive log list(查看归档状态)
检查源端数据库的附加日志是否打开:
SQL> select supplemental_log_data_min from v$database;
将附加日志打开:
SQL> alter database add supplemental log data;
切换日志使附加日志生效:
SQL> alter system archive log current;
关闭回收站:
SQL> alter system set recyclebin=off scope=spfile;
oracle 9i 无回收站,此部略


复制测试用户为scott,建库是已安装此样板数据库 :
解锁测试用户,并赋予想要的权限,简单起见赋予DBA权限,命令如下:
********************************************************
alter user scott identifieg by scott account unlock;
grant dba to scott;
********************************************************
上述两条命令在gg1,gg2,gg3上均作同样的操作。

目标端gg3配置:

oracle数据库设置
SQL> create user ggs identified by ggs account unlock;
SQL> grant dba to ggs
本次测试目标端未开启归档,未启用附加日志






2.6 源端gg1配置
配置抽取进程
gg1启用对象级别附加日志

$ sqlplus /nolog

SQL*Plus: Release 9.2.0.8.0 - Production on Mon May 12 03:34:46 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.

SQL> connect scott/scott
Connected.




SQL> select tname from tab;

TNAME
------------------------------
BONUS
DEPT
EMP
SALGRADE


$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg1.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          


GGSCI (gg1.abc.com) 2> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (gg1.abc.com) 3> add trandata scott.bonus

2014-05-12 03:39:48WARNING OGG-00869No unique key is defined for table BONUS. All viable columns will be used to represent the key, but may not guarantee uniqueness.KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table SCOTT.BONUS.

GGSCI (gg1.abc.com) 4> add trandata scott.dept

Logging of supplemental redo data enabled for table SCOTT.DEPT.

GGSCI (gg1.abc.com) 5> add trandata scott.emp

Logging of supplemental redo data enabled for table SCOTT.EMP.


GGSCI (gg1.abc.com) 7> add trandata scott.salgrade

2014-05-12 03:40:28WARNING OGG-00869No unique key is defined for table SALGRADE. All viable columns will be used to represent the key, but may not guarantee uniqueness.KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table SCOTT.SALGRADE.




GGSCI (gg1.abc.com) 8> edit params ext_my


extract ext_my
dynamicresolution
userid ggs,password ggs
exttrail /home/oracle/ggs/dirdat/my
table scott.*;

"dirprm/ext_my.prm" 5L, 108C written


GGSCI (gg1.abc.com) 9> view params ext_my

extract ext_my
dynamicresolution
userid ggs,password ggs
exttrail /home/oracle/ggs/dirdat/my
table scott.*;


GGSCI (gg1.abc.com) 10> add extract ext_my,tranlog,begin now
EXTRACT added.


GGSCI (gg1.abc.com) 11> add exttrail /home/oracle/ggs/dirdat/my,extract ext_my
EXTTRAIL added.


GGSCI (gg1.abc.com) 12> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:00:19   



源端gg1配置泵取进程


源端增加一个推送进程:
GGSCI (gg1.abc.com) 13> edit params pm_my1


extract pm_my1
passthru
dynamicresolution
userid ggs,password ggs
rmthost 192.168.1.208,mgrport 7809
rmttrail /home/oracle/ggs/dirdat/s1
table scott.*;
~
"dirprm/pm_my1.prm" 7L, 152C written


GGSCI (gg1.abc.com) 14> view params pm_my1

extract pm_my1
passthru
dynamicresolution
userid ggs,password ggs
rmthost 192.168.1.208,mgrport 7809
rmttrail /home/oracle/ggs/dirdat/s1
table scott.*;



添加推送进程读取的本地TRAIL文件:
GGSCI (gg1.abc.com) 15> add extract pm_my1,exttrailsource /home/oracle/ggs/dirdat/my
EXTRACT added.
添加推送进程发送到远端的trail目录:
GGSCI (gg1.abc.com) 16> add rmttrail /home/oracle/ggs/dirdat/s1,extract pm_my1
RMTTRAIL added.

查看:

GGSCI (gg1.abc.com) 17> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:08:15   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:01:44   



可以看到源端管理进程、抽取进程、泵取进程pm_my1、以配置完成,但未启动,

















下面开始
两个目标端测试用户的实例化


2.8 源端测试用户及目标端测试用户的实例化

实例化方式1:
本次测试的两个目标端及源端均是同一虚拟机克隆的快照,克隆前的虚拟机以安装数据库,并建立数据库测试用户,故
三个数据库的用户SCOTT的表对象处于一致的状态,可省略初始化过程


实例化方式2:
exp/imp 方式实例化


Example 2: schema export using exp
Enable Minimal Supplemental Logging in Oracle on source
SQLPLUS > alter database add supplemental log data;
Enable Supplemental Logging at Table Level on source
GGSCI> dblogin userid xxxxx password xxxxxx
GGSCI> add trandata <schema>.<tablename>
Add Extract, Add ExtTrail FileTrail File, Add Pump, Add RmtTrail FileTrail File on source

Start Extract, Start Pump on source
Get the current SCN on the source database:
SQLPLUS> select current_scn from v$database ;
CURRENT_SCN
-----------------------28318029
Get a flashback snapshot from the SCN that you obtained in the previous step. You can do this with
exp or expdp utility. The following example shows the use of export utility (exp):
>exp <username>/<password> owner=<schema_name> grants=n statistics=none triggers=n
compress=n FLASHBACK_SCN=28318029
Note: Undo_retention has to be set high enough, and the export log needs to be checked for errors.
You can speed up exp by running multiple session in parallel but you have to manually configure
subsets of the data you want to export (e.g. different tables for different export files). Make sure to use
the same FLASHBACK_SCN for all export sessions to ensure taking a read consistent backup.
Start an import to the target database when export is complete.
Add and Start Replicat:
GGSCI> add replicat <rename>, exttrail ./dirdat/<xx>
GGSCI> start replicat <rename>, aftercsn <SCN value returned from query on source>





2.9.1 中间库端配置复制进程rep_s1,此进程应用gg1投递进程的rmttrail

gg2启用对象级别附加日志

$ sqlplus /nolog

SQL*Plus: Release 9.2.0.8.0 - Production on Mon May 12 03:34:46 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.

SQL> connect scott/scott
Connected.




SQL> select tname from tab;

TNAME
------------------------------
BONUS
DEPT
EMP
SALGRADE


$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg2.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          


GGSCI (gg2.abc.com) 2> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (gg2.abc.com) 3> add trandata scott.bonus

2014-05-12 03:39:48WARNING OGG-00869No unique key is defined for table BONUS. All viable columns will be used to represent the key, but may not guarantee uniqueness.KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table SCOTT.BONUS.

GGSCI (gg2.abc.com) 4> add trandata scott.dept

Logging of supplemental redo data enabled for table SCOTT.DEPT.

GGSCI (gg2.abc.com) 5> add trandata scott.emp

Logging of supplemental redo data enabled for table SCOTT.EMP.


GGSCI (gg2.abc.com) 7> add trandata scott.salgrade

2014-05-12 03:40:28WARNING OGG-00869No unique key is defined for table SALGRADE. All viable columns will be used to represent the key, but may not guarantee uniqueness.KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table SCOTT.SALGRADE.

gg2:

$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg2.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING      



中间库添加检查点表


GGSCI (gg2.abc.com) 9> edit params ./GLOBALS


checkpointtable ggs.ckpt
~
~
"./GLOBALS" 1L, 25C written


GGSCI (gg2.abc.com) 10> view params ./GLOBALS

checkpointtable ggs.ckpt


GGSCI (gg2.abc.com) 11> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (gg2.abc.com) 12> add checkpointtable ggs.ckpt

Successfully created checkpoint table GGS.CKPT.                              

配置rep_s1:


GGSCI (gg2.abc.com) 2> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (gg2.abc.com) 3> edit params rep_s1


replicat rep_s1
userid ggs, password ggs
handlecollisons
assumetargetdefs
map scott.*, target scott.*;

"dirprm/rep.prm" 5L, 100C written


GGSCI (gg2.abc.com) 4> view params rep_s1

replicat rep_s1
userid ggs, password ggs
handlecollisions
assumetargetdefs
map scott.*, target scott.*;


GGSCI (gg2.abc.com) 5> dblogin userid ggs,password ggs
Successfully logged into database.




GGSCI (gg2.abc.com) 7> add replicat rep_s1, checkpointtable ggs.ckpt, exttrail /home/oracle/ggs/dirdat/s1
REPLICAT added.


GGSCI (gg2.abc.com) 8> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
REPLICAT    STOPPED   REP         00:00:00      00:00:06


2.9.2 中间库服务器配置抽取进程及投递进程,抽取本地数据变化,并发送到目标库端

中间库配置抽取进程





GGSCI (gg2.abc.com) 8> edit params ext_my


extract ext_my
dynamicresolution
userid ggs,password ggs
exttrail /home/oracle/ggs/dirdat/my
ignoreapplops,getreplicates
table scott.*;

"dirprm/ext_my.prm" 5L, 108C written


GGSCI (gg2.abc.com) 9> view params ext_my

extract ext_my
dynamicresolution
userid ggs,password ggs
exttrail /home/oracle/ggs/dirdat/my
ignoreapplops,getreplicates
table scott.*;

###ignoreapplops,getreplicates 参数表示忽略中间库应用对数据的修改,中间库Extract进程只抽取Replicat进程产生的修改

GGSCI (gg2.abc.com) 10> add extract ext_my,tranlog,begin now
EXTRACT added.


GGSCI (gg2.abc.com) 11> add exttrail /home/oracle/ggs/dirdat/my,extract ext_my
EXTTRAIL added.


GGSCI (gg2.abc.com) 12> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:00:19   



中间库gg2配置泵取进程


源端增加一个推送进程:
GGSCI (gg2.abc.com) 13> edit params pm_my1


extract pm_my1
passthru
dynamicresolution
userid ggs,password ggs
rmthost 192.168.1.209,mgrport 7809
rmttrail /home/oracle/ggs/dirdat/s1
table scott.*;
~
"dirprm/pm_my1.prm" 7L, 152C written


GGSCI (gg1.abc.com) 14> view params pm_my1

extract pm_my1
passthru
dynamicresolution
userid ggs,password ggs
rmthost 192.168.1.209,mgrport 7809
rmttrail /home/oracle/ggs/dirdat/s1
table scott.*;



添加推送进程读取的本地TRAIL文件:
GGSCI (gg1.abc.com) 15> add extract pm_my1,exttrailsource /home/oracle/ggs/dirdat/my
EXTRACT added.
添加推送进程发送到远端的trail目录:
GGSCI (gg1.abc.com) 16> add rmttrail /home/oracle/ggs/dirdat/s1,extract pm_my1
RMTTRAIL added.

查看:

GGSCI (gg1.abc.com) 17> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:08:15   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:01:44   



可以看到源端管理进程、复制进程、抽取进程、泵取进程pm_my1、以配置完成,但未启动,





3.0目标端gg3配置复制进程

$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg2.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          

配置rep_s1:


GGSCI (gg3.abc.com) 2> dblogin userid ggs,password ggs
Successfully logged into database.

GGSCI (gg3.abc.com) 3> edit params rep_s1


replicat rep_s1
userid ggs, password ggs
handlecollisons
assumetargetdefs
map scott.*, target scott.*;

"dirprm/rep.prm" 5L, 100C written


GGSCI (gg3.abc.com) 4> view params rep_s1

replicat rep_s1
userid ggs, password ggs
handlecollisions
assumetargetdefs
map scott.*, target scott.*;


GGSCI (gg3.abc.com) 5> dblogin userid ggs,password ggs
Successfully logged into database.




GGSCI (gg3.abc.com) 7> add replicat rep_s1, nodbcheckpoint, exttrail /home/oracle/ggs/dirdat/s1
REPLICAT added.


GGSCI (gg3.abc.com) 8> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
REPLICAT    STOPPED   REP         00:00:00      00:00:06










3.1 测试源端及目标端数据是否同步


GGSCI (gg1.abc.com) 16> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:08:39   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:07:43   


GGSCI (gg1.abc.com) 17> start ext_my

Sending START request to MANAGER ...
EXTRACT EXT_MY starting


GGSCI (gg1.abc.com) 18> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   RUNNING   EXT_MY      00:08:50      00:00:00   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:07:54   


GGSCI (gg1.abc.com) 19> start pm_my1

Sending START request to MANAGER ...
EXTRACT PM_MY1 starting


GGSCI (gg1.abc.com) 20> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   RUNNING   EXT_MY      00:08:50      00:00:06   
EXTRACT   RUNNING   PM_MY1      00:00:00      00:08:00   


gg2:



GGSCI (gg2.abc.com) 25> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:02:51   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:01:50   
REPLICAT    STOPPED   REP_S1      00:00:00      00:03:40   


GGSCI (gg2.abc.com) 26> start rep_s1

Sending START request to MANAGER ...
REPLICAT REP_S1 starting


GGSCI (gg2.abc.com) 27> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   STOPPED   EXT_MY      00:00:00      00:03:26   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:02:25   
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:02   


GGSCI (gg2.abc.com) 28> strart ext_my
ERROR: Invalid command.

GGSCI (gg2.abc.com) 29> start ext_my

Sending START request to MANAGER ...
EXTRACT EXT_MY starting


GGSCI (gg2.abc.com) 30> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   RUNNING   EXT_MY      00:00:00      00:03:42   
EXTRACT   STOPPED   PM_MY1      00:00:00      00:02:41   
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:09   


GGSCI (gg2.abc.com) 31> start pm_my1

Sending START request to MANAGER ...
EXTRACT PM_MY1 starting


GGSCI (gg2.abc.com) 32> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   RUNNING   EXT_MY      00:03:44      00:00:06   
EXTRACT   RUNNING   PM_MY1      00:00:00      00:02:49   
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:06   


gg3:


GGSCI (gg3.abc.com) 6> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
REPLICAT    STOPPED   REP_S1      00:00:00      00:00:10   


GGSCI (gg3.abc.com) 7> start rep_s1

Sending START request to MANAGER ...
REPLICAT REP_S1 starting


GGSCI (gg3.abc.com) 8> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:02   




测试:



$sqlplus scott/scott

SQL*Plus: Release 9.2.0.8.0 - Production on Wed May 14 23:39:31 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> select count(*) from emp;

COUNT(*)
----------
      14

SQL> select distinct empno from emp;

   EMPNO
----------
      7369
      7499
      7521
      7566
      7654
      7698
      7782
      7788
      7839
      7844
      7876

   EMPNO
----------
      7900
      7902
      7934

14 rows selected.

SQL> delete from emp where empno=7934;

1 row deleted.

SQL> commit;

Commit complete.

SQL>



目标端gg3:


$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg3.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:00   


GGSCI (gg3.abc.com) 2> stats rep_s1

Sending STATS request to REPLICAT REP_S1 ...

Start of Statistics at 2014-05-14 23:41:44.

Replicating from SCOTT.EMP to SCOTT.EMP:

*** Total statistics since 2014-05-14 23:41:30 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Daily statistics since 2014-05-14 23:41:30 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Hourly statistics since 2014-05-14 23:41:30 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Latest statistics since 2014-05-14 23:41:30 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

End of Statistics.


GGSCI (gg3.abc.com) 3> exit
$ sqlplus scott/scott

SQL*Plus: Release 9.2.0.8.0 - Production on Wed May 14 23:41:59 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> select count(*) from emp;

COUNT(*)
----------
      13

SQL>





查看中间库:




$ sqlplus scott/scott

SQL*Plus: Release 9.2.0.8.0 - Production on Wed May 14 23:43:39 2014

Copyright (c) 1982, 2002, Oracle Corporation.All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> select count(*) from emp;

COUNT(*)
----------
      13

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
$ ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100
Linux, x64, 64bit (optimized), Oracle 9i on Oct4 2011 23:49:32

Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.



GGSCI (gg2.abc.com) 1> info all

Program   Status      Group       Lag         Time Since Chkpt

MANAGER   RUNNING                                          
EXTRACT   RUNNING   EXT_MY      00:00:00      00:00:01   
EXTRACT   RUNNING   PM_MY1      00:00:00      00:00:01   
REPLICAT    RUNNING   REP_S1      00:00:00      00:00:05   


GGSCI (gg2.abc.com) 2> stats ext_my

Sending STATS request to EXTRACT EXT_MY ...

Start of Statistics at 2014-05-14 23:44:00.

Output to /home/oracle/ggs/dirdat/my:

Extracting from SCOTT.EMP to SCOTT.EMP:

*** Total statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Daily statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Hourly statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Latest statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

End of Statistics.


GGSCI (gg2.abc.com) 3> stats PM_MY1

Sending STATS request to EXTRACT PM_MY1 ...

Start of Statistics at 2014-05-14 23:44:11.

Output to /home/oracle/ggs/dirdat/s1:

Extracting from SCOTT.EMP to SCOTT.EMP:

*** Total statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Daily statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Hourly statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Latest statistics since 2014-05-14 23:41:27 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

End of Statistics.


GGSCI (gg2.abc.com) 4> stats REP_S1

Sending STATS request to REPLICAT REP_S1 ...

Start of Statistics at 2014-05-14 23:44:19.

Replicating from SCOTT.EMP to SCOTT.EMP:

*** Total statistics since 2014-05-14 23:41:25 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Daily statistics since 2014-05-14 23:41:25 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Hourly statistics since 2014-05-14 23:41:25 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

*** Latest statistics since 2014-05-14 23:41:25 ***
      Total inserts                              0.00
      Total updates                              0.00
      Total deletes                              1.00
      Total discards                               0.00
      Total operations                           1.00

End of Statistics.


GGSCI (gg2.abc.com) 5>






页: [1]
查看完整版本: Oracle 9.2.0.8 RHEL 4U GoldenGate V11.1.1.1.2 cascade 级联 DML 复制实践