ogg主库更新从库没有该记录的处理办法

目的库复制进程参数如下:
replicat repep
userid goldengate, password goldengate
DiscardFile ./dirrpt/repep.dsc, append, Megabytes 200
gettruncates
allownoopupdates
assumetargetdefs
dboptions suppresstriggers
dboptions deferrefconst
MAP ora12cpdb1.hxl.tb_test,TARGET hxl.tb_test;
MAP ora12cpdb1.hxl.tb_test01,TARGET hxl.tb_test01;
MAP ora12cpdb1.hxl.tb_test02,TARGET hxl.tb_test02;
ddlerror 10655 ignore
ddlerror 10636 ignore

源库进行更新操作
update hxl.tb_test t
set t.name='hxlname1111'
where Id=11;

复制进程报出现absend,错误如下:
OCI Error ORA-01403: no data found, SQL <UPDATE /*+ RESTRICT_ALL_REF_CONS */ "HXL"."TB_TEST" x SET x."NAME" = :a3 WHERE x."ID" = :b0>
Aborting transaction on /u01/ogg/dirdat/ep beginning at seqno 0 rba 6340

原因是:目的库没有id=11的记录导致的;

在复制进程参数加上handlecollisions后,进程可以正常启动,但是id=11的记录不会同步过去,我们要想实现更新的时候发现不存在的记录做insert写入操作,
可以针对每个maping加上resolveconflict处理,如下配置
replicat repep
userid goldengate, password goldengate
DiscardFile ./dirrpt/repep.dsc, append, Megabytes 200
gettruncates
allownoopupdates
assumetargetdefs
dboptions suppresstriggers
dboptions deferrefconst
--handlecollisions
MAP ora12cpdb1.hxl.tb_test,TARGET hxl.tb_test
resolveconflict (updaterowmissing, (default, overwrite));
MAP ora12cpdb1.hxl.tb_test01,TARGET hxl.tb_test01;
MAP ora12cpdb1.hxl.tb_test02,TARGET hxl.tb_test02;
ddlerror 10655 ignore
ddlerror 10636 ignore

这个要是更新的不是主键的话,需要在主库为每个列加上补充日志,如下:
alter database add supplemental log data (all) columns或是
alter table hxl.tb_test add supplemental log data(all) columns;


备注resolveconflict的常见使用:
map hxl.tb_test, target hxl.tb_test,
comparecols (on update all, on delete all),
resolveconflict (updaterowexists, (default, usemin (last_time))),
resolveconflict (deleterowexists, (default, overwrite)),
resolveconflict (deleterowmissing, (default, discard));

posted @ 2019-05-22 10:36  slnngk  阅读(969)  评论(0编辑  收藏  举报