OGG複製程序Not found處理
OGG運維,經常遇到複製程序ORA-01403: no data found,SQL error 程序報錯~
如下進行學習測試
1.資料重新初始化;
2.使用HANDLECOLLISIONS;
3.手工查詢差異資料,手工補資料。
1.測試資料準備
SQL> select * from dd; ID CC_NAME WITTIME ---------- -------------------- ---------------------------------------- 2 2 03-JUN-2002.34.37.000000 PM SQL> create table d1 as select * from dd; SQL> create table d2 as select * from dd; SQL> create table d3 as select * from dd; 源端 GGSCI (t1) 46> stop exta GGSCI (t1) 48> edit param exta table yz.d1; table yz.d2; table yz.d3; GGSCI (t1) 50> start exta GGSCI (t1) 49> stop dpea GGSCI (t1)51> edit param dpea table yz.d1; table yz.d2; table yz.d3; GGSCI (t1) 52> start dpea 目標端 SQL> create table d1 as select * from dd; SQL> create table d2 as select * from dd; SQL> create table d3 as select * from dd; GGSCI (t2) 18> edit param repa MAP YZ.D1,TARGET BAK_YZ.D1; MAP YZ.D2,TARGET BAK_YZ.D2; MAP YZ.D3,TARGET BAK_YZ.D3; GGSCI (t2)19> start repa
2.測試
情況1,源端add trandata之前存在資料變更導致OGG同步的表資料不一致,後續對這些資料update or delete操作時報錯
源端插入資料
SQL> insert into d1 values(3,3,sysdate); SQL> commit;
目標端查詢
SQL> select * from d1 where id=3;
no rows selected
源端此時對需要同步的表進行add trandata操作
GGSCI (t1) 57> dblogin USERID ogg,PASSWORD ogg
Successfully logged into database.
GGSCI (t1 as ogg@t1) 58> info trandata yz.d1
Logging of supplemental redo log data is disabled for table YZ.D1.
GGSCI (t1 as ogg@t1) 59> add trandata yz.d1
2020-07-28 10:16:33 WARNING OGG-06439 No unique key is defined for table D1. All viable columns will be used
to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key
GGSCI (t1 as ogg@t1) 60> info trandata yz.d1
Logging of supplemental redo log data is enabled for table YZ.D1.
Columns supplementally logged for table YZ.D1: "CC_NAME", "ID", "WITTIME".
Prepared CSN for table YZ.D1: 2717019
源端修改資料
SQL> update d1 set id=4 where id=3;
SQL> commit;
目標端複製程序Abend
GGSCI (t2) 48> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT ABENDED REPA 00:00:00 00:00:25
觀察報錯,資料未找到
GGSCI (t2) 51> view report repa
2020-07-29 02:25:17 WARNING OGG-01004 Aborted grouped transaction on BAK_YZ.D1, Database error 1403 (No data found).
2020-07-29 02:25:17 ERROR OGG-01296 Error mapping from YZ.D1 to BAK_YZ.D1.
觀察報錯資訊
[root@t2 ~]# tail -200f /u01/ogg/base/dirrpt/repa.dsc
Oracle GoldenGate Delivery for Oracle process started, group REPA discard file opened: 2020-07-29 02:24:36.856622
Current time: 2020-07-29 02:25:17
Discarded record from action ABEND on error 1403
No data found
Aborting transaction on /u01/ogg/base/dirdat/t1 beginning at seqno 29 rba 1,996
error at seqno 29 rba 1996
Problem replicating YZ.D1 to BAK_YZ.D1.
Record not found
Mapping problem with unified PK update record (target format) SCN:0.6.20.1573...
*
ID = 3
000000: 33 |3 |
CC_NAME = 3
000000: 33 |3 |
WITTIME = 2020-07-29 02:23:32.000000000
000000: 32 30 32 30 2d 30 37 2d 32 39 20 30 32 3a 32 33 |2020-07-29 02:23|
000010: 3a 33 32 2e 30 30 30 30 30 30 30 30 30 |:32.000000000 |
ID = 4
000000: 34 |4 |
CC_NAME = 3
000000: 33 |3 |
WITTIME = 2020-07-29 02:23:32.000000000
000000: 32 30 32 30 2d 30 37 2d 32 39 20 30 32 3a 32 33 |2020-07-29 02:23|
000010: 3a 33 32 2e 30 30 30 30 30 30 30 30 30 |:32.000000000 |
*
Process Abending : 2020-07-29 02:25:17.942993
處理方法:1.目標端手工插入缺少的資料,實際運維中比較少用,比較繁瑣;
2.重新初始化整個表資料;
3.使用引數 HANDLECOLLISIONS
目標端再次查詢,可以發現update 非主鍵資料不存在,則直接插入update修改後的值。
SQL> select * from d1;
ID CC_NAME WITTIME
---------- ---------- ---------------------------------------------------------------------------
2 2 03-JUN-20 02.34.37.000000 PM
4 3 29-JUL-20 02.23.32.000000 AM
情況2,目標端存在程式或人為對資料進行調整,後續對這些資料update or delete操作時報錯
模擬人為調整資料,刪除目標端環境資料
SQL> delete d1 where id=4;
1 row deleted.
SQL> commit;
目標端ogg程序,註釋HANDLECOLLISIONS引數
源端此時對資料進行delete操作
SQL> delete d1 where id=4;
1 row deleted.
SQL> commit; 源端存在id=4的值,但是目標端id=4的值已經被刪除。
果然,目標端OGG程序abend
REPLICAT ABENDED REPA
[root@t2 ~]# tail -20f /u01/ogg/base/dirrpt/repa.dsc
Aborting transaction on /u01/ogg/base/dirdat/t1 beginning at seqno 29 rba 2,723
error at seqno 29 rba 2723
Problem replicating YZ.D1 to BAK_YZ.D1.
Record not found
Mapping problem with delete record (target format) SCN:0.10.30.2405...
*
ID = 4
000000: 34 |4 |
CC_NAME = 3
000000: 33 |3 |
WITTIME = 2020-07-29 02:40:06.000000000
000000: 32 30 32 30 2d 30 37 2d 32 39 20 30 32 3a 34 30 |2020-07-29 02:40|
000010: 3a 30 36 2e 30 30 30 30 30 30 30 30 30 |:06.000000000 |
*
Process Abending : 2020-07-29 02:41:26.862051
再次使用HANDLECOLLISIONS 引數
目標端再次查詢,可以發現delete 非主鍵資料不存在,則直接忽略該Delete操作。
情況3,源端新增欄位,但是操作不規範,導致OGG not found
參考 https://www.cnblogs.com/lvcha001/p/13426495.html
1) 複製程序assumetargetdefs時,源端新增欄位,並未重新add trandata,導致部分新增欄位的資料,並未同步至目標端;
後續對目標端手工新增欄位,源端重新add trandata後,應用部分SQL 涉及新增欄位的資料,複製程序報錯;
重新初始化 Or 使用HANDLECOLLISIONS 引數
2)使用DEF檔案,delete trandata 之前存在insert資料,重啟複製程序後,OGG abend insert插入源端def檔案需要更新。