级联复制: node1 -> node2 ->node 3
[[email protected] dump_dir]$
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.199 dominic.mysql1 -->node1
192.168.0.195 dominic.mysql2 -->node2
192.168.0.171 dominic.node1 -->node3
概述: 做之前,我的node1-> node2 已经同步中,只是 需要在此基础上 做个node2 ->node3 的同步。
同时,node2 作为 中间库, 除了 配置接收 node1 来的数据 replicat 进程外,还需要 配置 抽取数据 extract 进程(extract, pump) . 注意,这两者 进程的 存放目录 独立分开。
node1 -> node2 (node1 extract目录:/dba/ogg/dirdat/st )
( node2 replicat目录: /dba/ogg/dirdat/tt)
node2 ->node3 (node2 extract 目录: /dba/ogg/dirdat/at)
( node3 replicat 目录: /dba/oggs/dirdat/bt)
另外: node2->node3 时, node3上的初始化数据可以使用 node2 的,我这里通过 expdp 初始化(数据小,测试)
仔细注意端口,其实不受影响
中间库node2 extract进程组必须添加: ignoreapplops,getreplicates
--重点这连个参数:
配置:
1: 配置 node 3 CHECKPOINTTABLE 参数 (node2 已经有了)
添加 node3 ./GLOBALS 参数 (如果是重做,这表在ogg 用户下可以先删除)
GGSCI (target) > edit params ./GLOBALS
checkpointtable ogg.checktable
GGSCI (target) > dblogin userid ogg,password ogg
GGSCI (target)>add checkpointtable ogg.checktable
2: node 2 配置 extract 进程 的 extra_2, pump_2 进程组参数,并启动这两个参数:
--extract
GGSCI (dominic.mysql2) 27> view params extra_2
extract extra_2
dynamicresolution
userid ogg,password ogg
--rmthost dominic.mysql2,mgrport 7809,compress
--rmthost 192.168.0.171,mgrport 7809,compress
reportcount every 1 minutes,rate
exttrail /dba/ogg/dirdat/at
ddl include all
ddloptions addtrandata, report
ignoreapplops,getreplicates --重点这连个参数:
table scott.*;
--pump
GGSCI (dominic.mysql2) 28> view params pump_2
extract pump_2
rmthost 192.168.0.171 ,mgrport 7809,compress
passthru
rmttrail /dba/oggs/dirdat/bt
dynamicresolution
table scott.*;
添加Extract 进程:
GGSCI (source) > add extract extra_2,
tranlog, begin now (第二次使用alter 。。。)
添加本地trail 文件,Extract组负责写这部分文件,pump进程负责读它。
GGSCI (source) > add exttrail /dba/ogg/dirdat/at ,
extract extra_2
----------------------------------------------------------
添加pump
进程:
GGSCI (source) > view params pump_2
GGSCI (source) > add extract pump_2,exttrailsource /dba/ogg/dirdat/at
GGSCI(source) > add rmttrail /dba/ogg/dirdat/bt,
extract pump_2 --投递到目标端对应的目录。
--启动后:
GGSCI (dominic.mysql2) 29> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXTRA_2 00:00:00 00:00:07
EXTRACT RUNNING PUMP_2 00:00:00 00:00:09
REPLICAT RUNNING REP_1 00:00:00 00:00:04
3 : 配置 node3 mgr 管理进程参数,并启动
--mgr
GGSCI (dominic.node1 as [email protected]) 31> view params mgr
PORT 7809
dynamicportlist 7810-7850
autostart er *
autorestart extract *,waitminutes 2, retries 5
lagreporthours 1
laginfominutes 3
lagcriticalminutes 5
purgeoldextracts /dba/ogg/bt*,usecheckpoints,minkeepdays 3
4: node 2 通过expdp 备份,并几下参数值 current_scn 号, 在expdp 参数 flashback_scn=xxxxx 标记出
5: 数据拷贝 node3 ,恢复,disable 约束。
6: 配置 node3 replicat 进程 rep_2 。并启动
--replicat
GGSCI (dominic.node1 as [email protected]) 33> view params rep_2
replicat rep_2
userid ogg,password ogg
assumetargetdefs
reperror default,discard
discardfile /dba/oggs/dirrpt/rep_2.dsc, append , megabytes 50
dynamicresolution
APPLYNOOPUPDATES
ddl include mapped
ddloptions report
DDLERROR DEFAULT IGNORE RETRYOP --加这个参数,是因为这是在以前的实验上操作,涉及一些ddl 数据可以忽略(查询笔记)
map scott.*,target scott.*;
添加 replicat rep_2 添加到
GGSCI
(target) > add replicat rep_2, exttrail /dba/ogg/dirdat/bt
GGSCI (target) > start rep_1
GGSCI (target) > info all
7 测试:
--node1 :
152 rows selected.
SQL> create table emp as select * from T_ORDERS;
Table created.
SQL> commit;
SQL> select count(*) from tab;
COUNT(*)
----------
153
--node2 :
SQL> select count(*) from tab;
COUNT(*)
----------
153
1 row selected.
--node3
SQL> select count(*) from tab;
COUNT(*)
----------
153
--node1
--node2
--node3
ogg_级联复制'