ogg 初始化完成后update不同步处理
作者简介:王旭,在数据库管理方面拥有10多年经验。精通主流数据库系统,在企业数据库管理、性能优化、架构设计和高可用性能解决方案方面拥有丰富得实践经验。目前拥有(ORACLE ACE、MYSQL OCP、PG ACE、PGCA、PGCE、PGCM)等数据库认证。
背景
当ogg复制端报错后,频闭一个表又出现另外一个表导致,我们很多时候一时无法找到问题,可以通过以下方法判断和解决: 1、目标端排除表,然后start 复制进程。 2、在ogg复制端修改参数,先追平,HANDLECOLLISIONS --ignore table dml error 3、追平后,然后再测试insert、delete、update修改;
解决办法
第一次,追平数据后测试这个报错的表
select * from WX.TEST打印 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test';
--delete from WX.TEST打印 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test';
insert into WX.TEST打印 values(25339256,3,2,1,111315,7,0,1,3,sysdate,'test','','','','');
update WX.TEST打印 set 打印标记=2 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test';
--查看ggserror.log日志
.TEST打印, Mapping error.
2025-03-29T20:48:16.726+0800 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep_120.prm: Repositioning to rba 440049388 in seqno 0.
2025-03-29T20:48:16.734+0800 WARNING OGG-01151 Oracle GoldenGate Delivery for Oracle, rep_120.prm: Error mapping from WX.TEST打印 to WX.TEST打印.
2025-03-29T20:48:16.760+0800 ERROR OGG-01296 Oracle GoldenGate Delivery for Oracle, rep_120.prm: Error mapping from WX.TEST打印 to WX.TEST打印.
2025-03-29T20:48:21.873+0800 INFO OGG-02333 Oracle GoldenGate Delivery for Oracle, rep_120.prm: Reading /ogg/dirdat/xe000000000, current RBA 440,049,388, 816 records, m_file_seqno = 0, m_file_rba = 440,049,761.
2025-03-29T20:48:21.879+0800 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, rep_120.prm: PROCESS ABENDING.
--查看discard file文件
Process Abending : 2025-03-29 20:14:13.427698
Oracle GoldenGate Delivery for Oracle process started, group REP_120 discard file opened: 2025-03-29 20:33:08.104520
Oracle GoldenGate Delivery for Oracle process stopped, group REP_120 : 2025-03-29 20:45:10.370411
Oracle GoldenGate Delivery for Oracle process started, group REP_120 discard file opened: 2025-03-29 20:45:27.608406
Key column 行数 (3) is missing from update on table WX.TEST打印
Key column 打印时间 (9) is missing from update on table WX.TEST打印
Key column 打印人 (10) is missing from update on table WX.TEST打印
Key column 特殊xx (11) is missing from update on table WX.TEST打印
Key column 待转出 (12) is missing from update on table WX.TEST打印
Key column xx内容 (13) is missing from update on table WX.TEST打印
Missing 6 key columns in update for table WX.TEST打印.
Current time: 2025-03-29 20:48:16
Discarded record from action ABEND on error 0
Aborting transaction on /ogg/dirdat/xe beginning at seqno 0 rba 440,049,388
error at seqno 0 rba 440049388
Problem replicating WX.TEST打印 to WX.TEST打印.
Mapping problem with unified update record (target format) SCN:126.3.1893...
*
xxID = 25339256
000000: 32 35 33 33 39 32 35 36 |25339256 |
页号 = 3
000000: 33 |3 |
行号 = 2
000000: 32 |2 |
病人ID = 111315
000000: 31 31 31 33 31 35 |111315 |
主页ID = 7
000000: 37 |7 |
--从上面可以看到ogg的更新貌似说丢失了行;接着看看事务日志捕获方式,发现只有schema级别的,表级别的没有;
-- 源端查询
SELECT * FROM dba_capture;
SELECT * FROM dba_capture_prepared_schemas;
SELECT * FROM dba_capture_prepared_tables d where TABLE_OWNER='WX' and table_name='TEST打印';
--目标端查询
select source_object_name, instantiation_scn, ignore_scn from dba_apply_instantiated_objects;
SELECT * FROM dba_apply_error;
SELECT * FROM dba_apply_progress;
select g.log_group_name name,
g.owner || '.' || g.table_name table_name,g.LOG_GROUP_TYPE,
g.always,
g.generated,
c.column_name
from dba_log_groups g, dba_log_group_columns c
where g.log_group_name = c.log_group_name(+)
and g.table_name = c.table_name(+)
and g.owner='WX';
select g.owner,count(distinct g.table_name) from dba_log_groups g group by g.owner order by 2;复制
第二次,把上面这个错误频闭了,然后再打开复制进程追平,再将生产库的复制日志方式改变下测试
mapexclude WX.TEST打印;
stop rep_120
start rep_120
--mapexclude WX.TEST打印;
stop rep_120
start rep_120
--yuanduan
stop ext_orcl
dblogin userid ogg,password ogg
GGSCI (WIN-HLLFNN2PJBP as ogg@orcl) 150> add trandata WX.TEST打印
2025-03-29 21:06:54 WARNING OGG-06439 No unique key is defined for table TEST打印. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
2025-03-29 21:06:54 INFO OGG-15130 No key found for table WX.TEST打印. All viable columns will be logged.
2025-03-29 21:06:54 INFO OGG-15132 Logging of supplemental redo data enabled for table WX.TEST打印.
2025-03-29 21:06:54 INFO OGG-15133 TRANDATA for scheduling columns has been added on table WX.TEST打印.
2025-03-29 21:06:54 INFO OGG-15135 TRANDATA for instantiation CSN has been added on table WX.TEST打印.
--再次查看附加日志是否被记录;
select LOG_GROUP_NAME, TABLE_NAME, LOG_GROUP_TYPE, ALWAYS from DBA_LOG_GROUPS where OWNER='WX';
start ext_orcl
--测试增删改
select * from WX.TEST打印 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test';
--delete from WX.TEST打印 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test';
insert into WX.TEST打印 values(25339256,3,2,1,111315,7,0,1,3,sysdate,'test1','','','','');
update WX.TEST打印 set 打印标记=5 where 打印时间 >to_date('2025-03-29 20:00:00','yyyy-mm-dd hh24:mi:ss') and xxid=25339256 and 打印人='test1';
后面再测试其它的表,都是这个问题,于是将附加日志批量调整如下方式:
add trandata 用户.*
--观察一段时间后,调整重建ogg恢复复制
总结
后续将持续分享,欢迎关注~
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。