最近,在goldengate的应用场景中,replicat进程经常出现append,start也启动不起来,查看日志,发现出现ora-01403错误,日志内容如下:
- 2012-09-27 19:06:39 INFO OGG-00996 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: REPLICAT C_R_C6 started.
- 2012-09-27 19:06:40 WARNING OGG-01004 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: Aborted grouped transaction on '***.TB_COMMON_CUSTEMPRELATION', Database error 1403 (OCI Error ORA-01403: no data found, SQL <UPDATE "***"."TB_COMMON_CUSTEMPRELATION" SET "PK" = :a0,"FK" = :a1,"CREATETIME" = :a2,"LASTMODIFYTIME" = :a3,"LINEID" = :a5,"DELETEFLAG" = :a6,"NOTE" = :a7,"VERSION" = :a11 WHERE "BRANCHID" = :b0 AND "CUSTID" = :b1 AND "BUSINESTYPECODE" = :b2 AND "STAFFID" = :b3>).
- 2012-09-27 19:06:40 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: Repositioning to rba 1829839 in seqno 19.
- 2012-09-27 19:06:40 WARNING OGG-01154 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: SQL error 1403 mapping ***.TB_COMMON_CUSTEMPRELATION to ***.TB_COMMON_CUSTEMPRELATION OCI Error ORA-01403: no data found, SQL <UPDATE "***"."TB_COMMON_CUSTEMPRELATION" SET "PK" = :a0,"FK" = :a1,"CREATETIME" = :a2,"LASTMODIFYTIME" = :a3,"LINEID" = :a5,"DELETEFLAG" = :a6,"NOTE" = :a7,"VERSION" = :a11 WHERE "BRANCHID" = :b0 AND "CUSTID" = :b1 AND "BUSINESTYPECODE" = :b2 AND "STAFFID" = :b3>.
- 2012-09-27 19:06:40 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: Repositioning to rba 1829839 in seqno 19.
- 2012-09-27 19:06:41 ERROR OGG-01296 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: Error mapping from ***.TB_COMMON_CUSTEMPRELATION to ***.TB_COMMON_CUSTEMPRELATION.
- 2012-09-27 19:06:41 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, C_R_C6.prm: PROCESS ABENDING.
从日志中分析,发现关键信息处为:
Database error 1403 (OCI Error ORA-01403: no data found, SQL <UPDATE "***"."TB_COMMON_CUSTEMPRELATION" SET "PK" = :a0,"FK" = :a1,"CREATETIME" = :a2,"LASTMODIFYTIME" = :a3,"LINEID" = :a5,"DELETEFLAG" = :a6,"NOTE" = :a7,"VERSION" = :a11 WHERE "BRANCHID" = :b0 AND "CUSTID" = :b1 AND "BUSINESTYPECODE" = :b2 AND "STAFFID" = :b3>)
于是使用logdump来分析,分析过程如下:
- GGSCI (WIN-O6ODS01HLMM) 119> info c_r_c6
- REPLICAT C_R_C6 Last Started 2012-09-27 10:29 Status ABENDED
- Checkpoint Lag 00:00:00 (updated 01:53:55 ago)
- Log Read Checkpoint File ./dirdat/cm000019
- 2012-09-27 04:00:47.720000 RBA 1771589
- 然后用logdump查看:
- Logdump 48 >open ./dirdat/cm000019
- LogTrail ***dirdat\cm000015 closed
- Current LogTrail is ***\dirdat\cm000019
- Logdump 49 >pos 1771589
- Reading forward from RBA 1771589
- Logdump 50 >n
- 2012/09/27 08:36:10.858.000 FieldComp Len 194 RBA 1776078
- Name: ***.TB_COMMON_CUSTEMPRELATION
- After Image: Partition 4 G m
- 0000 000d 0000 0009 3937 3035 3130 3030 3100 0100 | ........970510001...
- 0c00 0000 0833 3039 3130 3030 3600 0200 1500 0032 | .....30910006......2
- 3031 322d 3038 2d32 383a 3130 3a33 303a 3037 0003 | 012-08-28:10:30:07..
- 0015 0000 3230 3132 2d30 392d 3237 3a30 383a 3336 | ....2012-09-27:08:36
- 3a30 3900 0400 0700 0000 0346 5741 0005 000a 0000 | :09........FWA......
- 0000 0000 0000 0000 0006 000a 0000 0000 0000 0000 | ....................
- 0000 0007 0004 ffff 0000 0008 000f 0000 000b 4457 | ..................DW
- Column 0 (x0000), Len 13 (x000d)
- 0000 0009 3937 3035 3130 3030 31 | ....970510001
- Column 1 (x0001), Len 12 (x000c)
- 0000 0008 3330 3931 3030 3036 | ....30910006
- Column 2 (x0002), Len 21 (x0015)
- 0000 3230 3132 2d30 382d 3238 3a31 303a 3330 3a30 | ..2012-08-28:10:30:0
- 37 | 7
- Column 3 (x0003), Len 21 (x0015)
- 0000 3230 3132 2d30 392d 3237 3a30 383a 3336 3a30 | ..2012-09-27:08:36:0
- 39 | 9
- Column 4 (x0004), Len 7 (x0007)
- 0000 0003 4657 41 | ....FWA
- Column 5 (x0005), Len 10 (x000a)
- 0000 0000 0000 0000 0000 | ..........
- Column 6 (x0006), Len 10 (x000a)
- 0000 0000 0000 0000 0000 | ..........
- Column 7 (x0007), Len 4 (x0004)
- ffff 0000 | ....
- Column 8 (x0008), Len 15 (x000f)
- 0000 000b 4457 4930 3030 3531 3138 37 | ....DWI00051187
- Column 9 (x0009), Len 8 (x0008)
- 0000 0004 4253 3036 | ....BS06
- Column 10 (x000a), Len 15 (x000f)
- 0000 000b 5a49 5930 3030 3031 3836 36 | ....ZIY00001866
- Column 11 (x000b), Len 10 (x000a)
- 0000 0000 0000 0000 0002 | ..........
- Logdump 67 >
从上面的信息看,发现记录update操作时数据 信息不全,有的列没有值(这种情况要关注更新主键时goldengate的处理,此文暂不讨论),接着在target端查看要update的这条记录,发现没有(这情况是target端缺失update数据),再看replicat配置文件 信息:
- REPLICAT c_r_c6
- SETENV (NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK")
- GETENV (NLS_LANG)
- USERID ************
- --HANDLECOLLISIONS
- ASSUMETARGETDEFS
- --DDLERROR DEFAULT IGNORE RETRYOP
- --REPERROR DEFAULT, DISCARD
- MAP ***.TB_COMMON_CUSTEMPRELATION ,TARGET ***.TB_COMMON_CUSTEMPRELATION , keycols (BRANCHID, CUSTID, BUSINESTYPECODE, STAFFID);
handcollisions被 注释了,也就是说当target端缺失delete 、update数据时,target端无法自动处理。
解决:
停止replicat进程,先将要同步的表tb_common_custemprelation给跳过,然后将在目标端上重新初始化此表,保证源和目标上此表的数据是一致,然后再在replicat进程中将tb_commmon_custemprelation加进去,然后启动进程。
总结:此案例中是源目标端表中数据不一致导致的。
但是在goldengate应用场景中出现ORA-01403的原因有3个:
1) 如果是表字段不一致,需要修改表字段,异构数据库还需要重新生成表结构定义文件,再重启进程。
2) 如果是索引不一致,需要重建索引,异构数据库还需要重新生成表结构定义文件,再重启进程。
3) 遇到这种情况,不能先去对比两端的表结构(可能修改表结构的sql在后面执行),而应该先去查明原因。若是数据问题,可以跳过该表的同步,然后重新同步该表。
本文出自 “oracle研习” 博客,请务必保留此出处http://2874575.blog.51cto.com/2864575/1009786