GoldenGate:source端表有2个唯一键,target端错误的选择了主键
1,157 total views, 1 views today
写在最前:
这是14年我写的文章,曾经发布在chinaunix上(http://blog.chinaunix.net/uid/23284114.html),已经被chinaunix删除。
今天搜索问题,导引到itpub一篇博客上,看文章结构非常熟悉(该博客未注明转载自哪里)。查看了自己的云笔记,确认是我2014年10月写的文章。
感慨时间过的真快,转眼过去5年。
算上这次,chinaunix是我已知的第二次删除我的博客文章,以后可能越来越多。有必要把chinaunix上的文章都迁移过来。毕竟,自己的博客是可控的。
@target
1 2 3 4 5 |
2014-10-08 10:40:48 WARNING OGG-00869 Oracle GoldenGate Delivery for Oracle, r_xx.prm: No unique key is defined for table 'XXXXXXXXX_HIS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key. 2014-10-08 10:40:48 WARNING OGG-01431 Oracle GoldenGate Delivery for Oracle, r_xx.prm: Aborted grouped transaction on 'XXXXXXXXX_HIS', Mapping error. 2014-10-08 10:40:48 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, r_xx.prm: Repositioning to rba 40285753 in seqno 13692. 2014-10-08 10:40:49 WARNING OGG-01151 Oracle GoldenGate Delivery for Oracle, r_xx.prm: Error mapping from XXXXXXXXX_HIS to XXXXXXXXX_HIS. 2014-10-08 10:40:49 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, r_xx.prm: Repositioning to rba 40285753 in seqno 13692. |
问题原因:
1 |
2014-10-08 10:40:48 WARNING OGG-00869 Oracle GoldenGate Delivery for Oracle, r_xx.prm: No unique key is defined for table 'XXXXXXXXX_HIS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key. |
这条报错,提醒XXXXXXXXX_HIS没有唯一键。
但是,这个表实际上有唯一键。所以,ogg的这条报错很奇怪。
metalink有提示:
Replicat Abending With Mapping Error and discard file shows Missing Key Columns (文档 ID 1276538.1)
If source table contains two unique indexes, during DDL change extract may choose and log incorrect column as primary key column which is due to bug in extract’s code while sorting unique indexes, resulting in replicat process abend with missing key columns options.
文中提示,source端表有2个唯一键,抽取进程可能选择的将唯一键作为了主键(这是一个bug)。
该bug反应出的现象是,replicat进程abend,然后提示“No unique key is defined”。
解决办法:
在source和target端,问题表后面都加上keycols选项,告诉ogg真正的主键。
添加keycols参数后解决问题。
MAP XXXXXXXXX_HIS ,TARGET XXXXXXXXX_HIS , keycols(id) ;
总结:如果source端表有2个唯一键,那么一定在extract参数中用keycols参数指出主键列。
target端replicat进程参数也要用keycols参数指出主键列。