您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)ogg中關(guān)于handlecollisions的示例分析,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
handlecollisions
實(shí)驗(yàn)環(huán)境參數(shù)
GGSCI (pc6 as ogg@hyyk) 11> edit params ext_s1
extract ext_s1
setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
setenv (ORACLE_SID="hyyk")
userid ogg,password oracle
gettruncates
exttrail /u01/app/oggs/dirdat/ss
table sender.*;
GGSCI (pc6 as ogg@hyyk) 13> edit params pump_s1
extract pump_s1
passthru
userid ogg,password oracle
rmthost 192.168.1.80,mgrport 7809
rmttrail /u01/app/oggd/dirdat/sd
table sender.*;
GGSCI (ogg-80) 5> edit params rep_s1
replicat rep_s1
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
setenv(ORACLE_SID='ogg')
userid ogg,password oracle
--handlecollisions
ASSUMETARGETDEFS
--SOURCEDEFS /u01/app/oggd/dirdef/test.def
DISCARDFILE ./dirrpt/rorabb.dsc,PURGE
userid ogg,password oracle
map sender.tb21,target receiver.tb21;
1、源和目標(biāo)建表(當(dāng)然源和目標(biāo)都要有主鍵)
源:
create table tb21(col1 int primary key, col2 int);
insert into tb21 values(1,1);
insert into tb21 values(2,1);
insert into tb21 values(3,1);
insert into tb21 values(4,1);
commit;
查看數(shù)據(jù)
SENDER@hyyk> select * from tb21;
COL1 COL2
---------- ----------
1 1
2 1
3 1
4 1
目標(biāo):
create table tb21(col1 int primary key, col2 int);
insert into tb21 values(1,1);
commit;
查看數(shù)據(jù)
RECEIVER@ogg> select * from tb21;
COL1 COL2
---------- ----------
1 1
添加附加日志,加入復(fù)制鏈路
GGSCI (pc6 as ogg@hyyk) 8> add trandata sender.tb21
Logging of supplemental redo data enabled for table SENDER.TB21.
TRANDATA for scheduling columns has been added on table 'SENDER.TB21'.
TRANDATA for instantiation CSN has been added on table 'SENDER.TB21'.
2、測(cè)試delete
無(wú)handlecollisions
源:
delete from tb21 where col1=2;
commit;
目標(biāo)端查看進(jìn)程狀態(tài)
GGSCI (ogg-80) 24> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT ABENDED REP_S1 00:00:04 00:00:02
復(fù)制進(jìn)程abend,2018-03-18 11:09:38 ERROR OGG-01296 Error mapping from SENDER.TB21 to RECEIVER.TB21.
可以在目標(biāo)上設(shè)置: 加handlecollisions(或者start rep2, skiptransaction)可以跳過(guò),用stats rep2看一下;
GGSCI (ogg-80) 32> stats rep_s1
Sending STATS request to REPLICAT REP_S1 ...
Start of Statistics at 2018-03-18 11:13:44.
Replicating from SENDER.TB21 to RECEIVER.TB21:
*** Total statistics since 2018-03-18 11:13:34 ***
Total inserts 0.00
Total updates 0.00
Total deletes 1.00
Total discards 0.00
Total operations 1.00
Total delete collisions 1.00
這里的delete變成了delete collisions
3、測(cè)試update
如果目標(biāo)上不存在這個(gè)記錄
(1)update鍵值時(shí):
源:
update tb21 set col1=5 where col1=3;
commit;
SENDER@hyyk> select * from tb21;
COL1 COL2
---------- ----------
1 1
5 1
4 1
無(wú)handlecollisions時(shí),會(huì)abend;
有handlecollisions時(shí),會(huì)變成insert;但是此時(shí)需要加:源端:FETCHOPTIONS FETCHPKUPDATECOLS(將捕獲完整日志鏡像到trail中,轉(zhuǎn)換為對(duì)target的一個(gè)完整記錄的插入,相當(dāng)于fetchcol(*))
目標(biāo)端查看
RECEIVER@ogg> select * from tb21;
COL1 COL2
---------- ----------
5 1
1 1
我們使用logdump查看trail
2018/03/18 11:20:44.000.000 GGSUnifiedPKUpdate Len 31 RBA 1830
Name: SENDER.TB21 (TDR Index: 1)
After Image: Partition 12 G s
0000 0009 0000 0005 0000 0001 3300 0000 0500 0000 | ............3.......
0135 0001 0005 0000 0001 31 | .5........1
Before Image Len 13 (x0000000d)
BeforeColumnLen 9 (x00000009)
Column 0 (x0000), Len 5 (x0005)
After Image Len 18 (x00000012)
Column 0 (x0000), Len 5 (x0005)
Column 1 (x0001), Len 5 (x0005)
(2)update非鍵值時(shí):
源:
update tb21 set col2=4 where col1=4;
commit;
SENDER@hyyk> select * from tb21;
COL1 COL2
---------- ----------
1 1
6 5
5 1
4 4
加了handlecollisions
RECEIVER@ogg> select * from tb21;
COL1 COL2
---------- ----------
4 4
5 1
1 1
6 5
如果是ogg11g 加了handlecollisions也沒(méi)有反應(yīng),數(shù)據(jù)也會(huì)不一致
需要在目標(biāo)端加入INSERTMISSINGUPDATES參數(shù),即可解決。
4、測(cè)試insert
源端insert的pk和目標(biāo)沖突時(shí),會(huì)以源端為準(zhǔn);
目標(biāo)首先插入一條:
insert into tb21 values(6,1);
commit;
RECEIVER@ogg> select * from tb21;
COL1 COL2
---------- ----------
5 1
1 1
6 1
然后源端插入:
insert into tb21 values(6,5);
SENDER@hyyk> select * from tb21;
COL1 COL2
---------- ----------
1 1
6 5
5 1
4 1
加handlecollisions,
RECEIVER@ogg> select * from tb21;
COL1 COL2
---------- ----------
5 1
1 1
6 5
看最后目標(biāo)的記錄如何,實(shí)際會(huì)變成以源端為準(zhǔn)。
看完上述內(nèi)容,你們對(duì)ogg中關(guān)于handlecollisions的示例分析有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。