1 实际应用案例 单项 0 - 0
双项 0 = 0
点对点多业务中心 01 - 02 - 03 - 01
一对多 0 - O1 | 0 - 02 | 0 - 03
多对一 01 - 0 | 02 - 0 | 03 - 0
多级层次 0 - 0 -01 | 0 - 0 -02 | 0 - 0 -03
2 配置 单源 到 多源,可以用两种方法: 独立 extract模式 和共享 extract 模式。
================配置独立模式====================================
独立extract 配置: --多条线,独立,不影响。 --几条完整的 extract,pump,replicat 链路结合。MGR 进程各一个
配置MGR 进程 (source)
GGSIC > edit params mgr
PORT 7839
DYNAMICPORTLIST 7840-7849
--AUTOSTART EXTRACT *
--AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3
PURGEOLDEXTRACTS ./dirdat/*,usercheckpoints,minkeepdays 100
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45
配置source Extract 进程参数:
GGSCI > edit params extma
EXTRACT extma
userid ggs,password ggs
setenv (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
GETTRUNCATES
REPORTCOUNT EVERY 1 MINUTES,RATE
numfiles 50000
DISCARDFILE ./dirrpt/extma.dsc ,APPEND,MEGABYTES 50
WARNLONGTRANS 2h,CHECKINTERVAL 3m
EXTTRAIL ./dirdat/ma
DBOPTIONS ALLOWUNUSEDCOLUMN
TRANLOGOPTIONS CONVERTUCS2CLOBS
DYNAMICRESOLUTION
TABLE SCOTT.*;
SEQUENCE SCOTT.*;
添加 source端 extract 进程组:
GGSCI > add extract extma,tranlog,begin now
GGSCI > add exttrail ./dirdat/ma,extract extma,megabytes 500
配置source端 PUMP 进程参数:
GGSCI > edit params dpema
EXTRACT dpema
RMTHOST ip_addr, MGRPORT 7839, compress
PASSTHRU
numfiles 50000
RMTTRAIL ./dirdat/ma
DYNAMICRESOLUTION
TABLE scott.*;
SEQUENCE scott.*;
添加 source端pump进程组:
GGSCI > add extract dump,exttrailsource ./dirdat/ma
GGSCI > add RMTTRAIL ./dirdat/ma, EXTRACT dpema, MEGABYTES 500
配置target端Replicat 进程参数:
GGSCI > edit params repma
REPLICAT repma
userid ggs,password ggs
setenv (NLS_LANG=“AMERICAN_AMERICA.ZHS16GBK")
--REPORT AT 01:59
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT,abend
numfiles 50000
DBOPTIONS ALLOWUNUSEDCOLUMN
MAXTRANSOPS 50000
GROUPTRANSOPS 10000
CHECKPOINTSECS 40
--HANDLECOLLISTIONS
assumetargetdefs
DISCARDFILE ./dirrpt/repma.dsc,APPEND,MEGABYTES 1000
GETTRUNCATES
ALLOWNOOPUPDATES
map scott.*,target scott.*;
配置target端checkpoint表
GGSCI > edit params ./GLOBALS
checkpointtable ggs.ckpt
dblogin userid ggs,password ggs
add checkpointtable ggs.ckpt
添加target端replicat 进程组:
GGSCI > add replicat repma,exttrail ./dirdat/ma checkpointtable ggs.ckpt
===================配置共享模式==============================
source端 配置一个统一的extract,然后通过不同data pump 分发数据。
共享EXtract的配置方法:
1 source端,target端配置MGR 进程参数
2 在source端添加 extract进程和本地Trail 文件。
add exract <ext>,tranlog,begin<time>,[,threads]
add exttrail <local_trail>,extract <ext>
3 编辑extract进程组参数文件,简单设置,具体可以参照以上设置。
extract <ext>
[sourcedb <dsn_1>,][userid <user>[,password <pw>]]
exttrail <local_trail>
table <owner>.<table>;
4 添加两个PUMP 进程组,这是这共享案例的关键,通过两个pump进程转发:
add extract <pump_1>,exttrailsource <local_trail>,begin<time>
add extract <pump_2>,exttrailsource<local_trail>,begin<time>
5 添加2个远程trail 文件队列:
add rmttrail <remote_trail_1>,extract<pump_1>
add rmttrail <remote_trail_2>,extract<pump_2>
6配置两个pump进程组参数文件:
--------------pump1 --------------------------------
extract <pump_1>
[source <dsn-1>,][userid <user>[,pasword <pw>]]
RMTHOST <TARGET_1>,mgrport <portnumber>
rmttrail <remote_trail_1>
[passthru|nopassthru]
table <owner>.<table>;
--------------pump2 ----------------------------------
extract <pump_2>
[source <dsn-1>,][userid <user>[,pasword <pw>]]
RMTHOST <TARGET_2>,mgrport <portnumber>
rmttrail <remote_trail_2>
[passthru|nopassthru]
table <owner>.<table>;
7 在target 端添加replicat进程:
add replicat <rep_1>,exttrail <remote_trail_1>,begin <time>
add replicat <rep_2>,exttrail <remote_trail_2>,begin <time>
8 配置target你端每个replicat 进程参数:
---------------replicat 1 ------------------------------
replicat <rep_1>
sourcedefs <full_pathname> | assumetargetdefs
[targetdb <dsn_2>,][userid <user id >[,password <pw>]]
repreeor (<error>,<response>)
map <owner>.<table>,target <owner>.<table>[,def <template name>];
--------------replicat 2 --------------------------------
replicat <rep_2>
sourcedefs <full_pathname> | assumetargetdefs
[targetdb <dsn_3>,][userid <user id >[,password <pw>]]
repreeor (<error>,<response>)
map <owner>.<table>,target <owner>.<table>[,def <template name>];
===============单表到多表复制==========================
单表到多表 与 单source 到 多target端的复制 相似。单表到多表,在任何模式可以配置,只需在target端配置map 参数即可。
单表到多表模式: --几种形式。
1 单表到相同(不同)数据库相同schema下 不同表名的复制。
2 单表到相同(不同)数据库不同schema 下相同表名的复制。
3 单表到相同(不同)数据库不同schema 下不同表名的复制。
下面的参数配置,把一张表复制到3个表中的配置方法。
map lifeman.gg_pol_ben , target elisdata.pol_ben;
map lifeman.gg_pol_ben , traget elisdata.pol_insured, colmap (usedefaults, clientno = insno);
map lifeman.gg_pol_ben , target elisdata.plol_jnt_insured, colmap ( usedefaults, clientno = jnt_insno);
-----以上例子,是所有source primary Key 与 target primary key 相同,如不同需要使用keycols指定。
单表拆分到单表,多表的复制:
replicat 1:
map sales.acct , target sales.acct ,filter (@range (1,2));
replicat 2:
map sales.acct , target sales.acct , filter (@range (2,2));
map sales.acct , target sales.acct , filter (@range (2,2));
=================多对一复制 ================================
多对一复制,一般使用在otap 数据仓库中。
多对一模式个链路相互独立,无法对replicat 进程合并。 建议每隔replicat进程的数据 使用不同的schema来存储。
eg 介绍 二对一 数据仓库的配置方法:
1, 为每个系统创建一个MGR 进程
2 ,source 使用add extract 命令为每个系统添加主抽取进程组。 分别交ext_1, ext_2:
extract_1
add extract <ext_1> ,tranlog ,begin <time> [,threads <n>]
extract _2
add extract <ext_2> ,tranlog ,begin <time> [,threads <n>]
3 source 端使用 add exttrail 命令为每个系统添加trail文件:
extract_1
add exttrail <local_tail_1>,extract <ext_1>
extract_2
add exttrail <local_tail_1>,extract <ext_2>
4 使用edit params 命令为每个extract 进程组编辑参数:
extract_1
extract <ext_1>
[source <dsn_1>,[userid <user>[,password <pw>]]
exttrail <local_trail_1>
table <owner>.<table>;
extract_2
extract <ext_2>
[source <dsn_2>,[userid <user>[,password <pw>]]
exttrail <local_trail_2>
table <owner>.<table>;
5 source为每个系统添加pump 进程,分别pump_1, pump_2 ,要exttrailsource属性来标识需要pump 进程读取trail 文件:
data pump_1
add extract <pump_1>, exttrailsource <local_trail_1>,begin <time>
data pump_2
add extract <pump_2>, exttrailsource <local_trail_2>,begin <time>
6 source 端使用命令add rmttrail 为pump 进程指定target trail 文件:
remote_1
add rmttrail <remote_trail_1> ,extract <pump_1>
remote_2
add rmttrail <remote_trail_2> ,extract <pump_2>
7 为pump 进程添加参数:
data pump_1
extract <pump_1>
[source <dsn_1>,][userid <user>[,password <pw>]]
rmthost <target>, mgrport <portnumber>
rmttrail <remote_trail_1>
<passthru | nopassthru]
table <owner>.<table>;
data pump_2
extract <pump_2>
[source <dsn_2>,][userid <user>[,password <pw>]]
rmthost <target>, mgrport <portnumber>
rmttrail <remote_trail_2>
<passthru | nopassthru]
table <owner>.<table>;
8 target 端使用命令 add replicat 添加replicat 进程组:
replicat_1
add replicat <rep_1> ,exttrail <remote_trail_1>, begin <time>
replicat_2
add replicat <rep_2>, exttrail <remote_trail_2>, begin <time>
9 为target 端replicat 进程添加参数:
replicat_1
replicat <rep_1>
sourcedefs <full_pathname> | assumetagetdefs
[targetdb <dsn_3>,][userid <user_Id>[,password <pw>]]
reperror (<error>,<response>)
map <owner>.<table>, target <owner>.<table>[,def <template name>];
replicat_2
replicat <rep_2>
sourcedefs <full_pathname> | assumetagetdefs
[targetdb <dsn_3>,][userid <user_Id>[,password <pw>]]
reperror (<error>,<response>)
map <owner>.<table>, target <owner>.<table>[,def <template name>];
=====================多表到单表======================
经常出现在有相同主键,相同数据问题,当target端出现重复记录时候,
可以使用 OVERRIDEDUPS 或 nooverridedups 参数来控制replica进程是否覆盖target中存在的数据。
通过参数 getdeletes | ignoredeletes 来控制gg 的replicat 是否忽略delete 操作。
eg 一下使用 overridedups参数覆盖已存在的记录,使用ignoredeletes 参数让replicat 进程忽略删除操作。
overridedupsp
map elisdata.client_base, target lifedata.client_info;
ignoredeletes
map elisdata.client_extend, target lifedata.client_info, &colump (usedefaults,
phoneticize_lastname= lastname,
phoneticize_firstname=firstname);
map elisdata.site_emai, target lifedata.client_info, & colmap (usedefaults, e_mail=email);
===========================级联复制======================
级联复制原理: (source端 --- 中间库端 ---- target 端)
a : source 端target 进程组抽取数据变化 到本地 trail 文件,Pump 进程传送到中间库端。
b: 中间库端replicat 进程复制数据到中间库
c: 中间库 配置extract 进程抽取数据变化到中间本地trail 文件,中间库配置pump 进程组,投递到target端、
d: target端 replicat 进程复制数据到target端库。
1 source 配置:
使用 add extract 命令创建名为 ext_1 的extract 进程:
add extract <ext_1>, tranlog , begin <time>[,threads <n>]
2 source 使用add EXTTRAIL 命令创建本地trail 文件:
ADD EXTTRAIL <LOCAL_TRAIL_1>,EXTRACT <EXT>
3 使用EDIT PARAMS 命令 ext_1 编辑参数:
EXTRACT <EXT_1>
[SOURCEDB <DSN_1>,][USERID <USER>[,PASSWORD <PW>]]
EXTTRAIL <LOCAL_TRAIL_1>
TABLE <OWNER>.<TABLE>;
4 在source使用 ADD EXTRACT 命令添加pump参数:
add extract <pump_1> ,exttrailsource <local_trail_1>,begin <time>
5 在source端使用add remotetrail 命令为pump进程添加远端 trail文件:
add rettrail <remote_trail_1> , extract <pump_1>
6 为source 端 pump 进程添加参数:
extract <pump_1>
[source <dsb_1>,][userid <user>[,password <pw>]]
rmthost <target_1>,mgrport <portnumber>
rmttrail <remote_trail_1>
[passthrn | nopassthru]
table <owner>.<table>;
7 中间库配置:
7.1 中间端添加 检查表:
edit params ./GLOBALS --一下编辑参数
checkpointtable ggs.ckpt
dblogin userid ggs, password ggs
add checkpointtable ggs.ckpt
7.2 中间端使用 add replicat 命令添加 replicat 进程:
add replicat <rep_1>, exttrail <remote_trail_1>, begin <time>
7.3 中间端为replicat 进程编辑参数:
replicat <rep_1>
sourcedefs <full_pathname> | assumetargetdefs
[targetdb <dsn_2>,][user id>[,password <pwd>]]
reperror (<error>,<response>)
map <owner>.<table> ,target <owner>.<table> [,def <template name>];
7.4 中间库 端添加名称为 ext_2 的extract进程组:
add extract <ext_2> ,tranlog,begin <time> [,threads <n>]
7.5 中间库端 为ext_2 添加 trail 文件:
add exttrail <local_trail_2>, extract <ext_2>
7.6 中间库端为ext_2编辑参数文件:
extact <ext_2>
[sourcedb <dsn_2>,][userid <user>[,password <pwd>]]
exttrail <local_trail_2>
ignoreapplops , getreplicates
table <owner>.<table>;
--- ignoreapplops 和 getreplicates 参数表示忽略中间库应用对数据的修改,中间库extract 进程只抽取replicat 进程产生的修改。
7.7 中间库端 pump进程,投递到target端;
add extract <pump_2> ,exttrailsource <local_trail_2>,begin <time>
7.8 中间库为pump_2 添加 源端trail 文件
add rettrail <remote_trail_2> , extract <pump_2>
7.9 为中间库pump_2 编辑参数文件:
extract <pump_2>
[sourcedb <dsn_2>,][userid <user>[,password <pwd>]]
rmthost <target_2>,mgrport <portnumber>
rmttrail <remote_trail_2>
[passthru | nopassthru]
table <owner>.<table>;
8 target端 的配置
8.1 目标库 添加replicat 进程,把中间端抽取过来的数据复制到target端数据库:
add replicat <rep_2> ,exttrail <remote_trail_2>,begin <time>
8.2 为rep_2 编辑参数文件:
replicat <rep_2>
sourcedefs <full_pathname> | assumetargetdefs
[targetdb <dsn_3>,][user id>[,password <pwd>]]
reperror (<error>,<response>)
map <owner>.<table> ,target <owner>.<table> [,def <template name>];
======================================primary-standby 模式切换 =====================
----详见P104 页
正常情况下,只有 source上的 extract,pump 进程和 target上replicat 进程运行,
而备库上的 extract,pump进程和source端库上的replicat 进程要停止,业务切换后,在打开。
============================配置 双向复制 active - active 模式============================
-----P111 页
此模式不支持DDL、sequence 双向复制操作。