实验目的:模拟OGG的abended状态,并修复。
本实验适用于在源端和目标端没有建立DDL复制功能的OGG。
步骤:
源端:
SQL> create table ogg_user.test(avarchar2(5));
Table created.
目标端:
SQL> create table ogg_user.test(avarchar2(2));
Table created.
源端:
SQL> insert into ogg_user.test values('11');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> select * from ogg_user.test;
A
-----
11
目标端:
SQL> select * from ogg_user.test;
A
--
11
源端:
SQL> insert into ogg_user.test values('111');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
目标端:
查看数据,没有变化,说明不符合的数据没有插入。
SQL> select * from ogg_user.test;
A
--
11
目标端:
GGSCI (oggtarget.localdomain) 10> info rep_rev
REPLICAT REP_REV Last Started 2015-08-0609:27 Status ABENDED
Checkpoint Lag 00:00:04 (updated 00:00:38 ago)
Log Read Checkpoint File ./dirdat/tv000000
2015-08-0609:39:26.249709 RBA2076
源端:
SQL> insert into ogg_user.test values('222');
1 row created.
SQL> insert into ogg_user.test values('22');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
目标端:
(1)./ggsci中可以看出RBA依然是 2076
GGSCI (oggtarget.localdomain) 11> info rep_rev
REPLICAT REP_REV Last Started 2015-08-0609:27 StatusABENDED
Checkpoint Lag 00:00:04 (updated 00:18:34 ago)
Log Read Checkpoint File ./dirdat/tv000000
2015-08-06 09:39:26.249709 RBA 2076
(2)出错信息是2076的这个事务,原因为value too large for column"OGG_USER"."TEST"."A" (actual:3, maximum: 2)
GGSCI (oggtarget.localdomain) 12> view report rep_rev
省略……….
***********************************************************************
** Run Time Messages **
***********************************************************************
Opened trail file ./dirdat/tv000000 at2015-08-06 09:27:26
Wildcard MAP resolved (entry OGG_USER.*):
MAP"OGG_USER"."TEST",TARGET OGG_USER."TEST";
2015-08-06 09:27:29 WARNING OGG-00869 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 u
sed to define the key.
Using following columns in default map by name:
A
Using the following key columns for targettable OGG_USER.TEST: A.
省略…………………
2015-08-06 09:39:31 WARNING OGG-00869 OCI Error ORA-12899: value too large forcolumn "OGG_U
SER"."TEST"."A"(actual: 3, maximum: 2) (status = 12899). INSERT INTO"OGG_USER"."TEST" ("A")
VALUES (:a0).
2015-08-06 09:39:31 WARNING OGG-01004 Aborted grouped transaction on'OGG_USER.TEST', Databa
se error 12899 (OCI ErrorORA-12899: value too large for column"OGG_USER"."TEST"."A" (actual:
3, maximum: 2) (status = 12899). INSERT INTO"OGG_USER"."TEST" ("A") VALUES (:a0)).
2015-08-06 09:39:31 WARNING OGG-01003 Repositioning to rba 2076 in seqno 0.
2015-08-06 09:39:31 WARNING OGG-01154 SQL error 12899 mapping OGG_USER.TEST toOGG_USER.TEST
OCI Error ORA-12899: value too large forcolumn "OGG_USER"."TEST"."A" (actual: 3, maximum:2)
(status = 12899). INSERT INTO"OGG_USER"."TEST" ("A") VALUES (:a0).
2015-08-06 09:39:31 WARNING OGG-01003 Repositioning to rba 2076 in seqno 0.
省略…………………..
2015-08-06 09:39:31 ERROR OGG-01296 Error mapping fromOGG_USER.TEST to OGG_USER.TEST.
省略…………………
(3)./logdump查询出在2076之后还有两个事务(就是插入222和22的事务),RBA 2201和 RBA 2201
Logdump 54 >open ./dirdat/tv000000
LogTrail /home/goldengate/ogg/dirdat/tv000000 closed
Current LogTrail is/home/goldengate/ogg/dirdat/tv000000
Logdump 55 >pos eof
Reading in reverse from RBA 2429
Logdump 56 >pos reverse
Reading in reverse from RBA 2429
Logdump 57 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 11 (x000b) IO Time : 2015/08/06 09:51:59.256.924
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x02) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 43 AuditPos : 48656
Continued : N (x00) RecCount : 1 (x01)
2015/08/06 09:51:59.256.924 Insert Len 11 RBA 2326
Name: OGG_USER.TEST
After Image: Partition 4 G e
00000007 0000 0003 3232 3f | ........22?
Logdump 58 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 11 (x000b) IO Time : 2015/08/0609:51:59.256.924
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x00) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 43 AuditPos : 48144
Continued : N (x00) RecCount : 1 (x01)
2015/08/06 09:51:59.256.924 Insert Len 11 RBA 2201
Name: OGG_USER.TEST
After Image: Partition 4 G b
00000007 0000 0003 3232 32 | ........222
Logdump 59 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 11 (x000b) IO Time : 2015/08/06 09:39:26.249.709
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x03) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 42 AuditPos : 27011088
Continued : N (x00) RecCount : 1 (x01)
2015/08/06 09:39:26.249.709 Insert Len 11 RBA 2076
Name: OGG_USER.TEST
After Image: Partition 4 G s
00000007 0000 0003 3131 31 | ........111
参数解释:
pos:是position的简写,定位文件中的位置(其中eof参数 是文件的末端,reverse是反向读取)。
n:是next的缩写,跳跃到下一个记录。
目标端:
(1)更改字段长度
SQL> alter table ogg_user.test modify avarchar(5);
Table altered.
(2)在./ggsci中,重置读取进程,重新从0号trial文件读取RBA 2076
注释:extseqno 0是因为./dirdat/tv000000是0号文件,extrba 2076是因为RBA是 2076。
GGSCI (oggtarget.localdomain) 1> info rep_rev
REPLICAT REP_REV Last Started 2015-08-06 09:27 Status ABENDED
Checkpoint Lag 00:00:04(updated 00:36:18 ago)
Log Read Checkpoint File ./dirdat/tv000000
2015-08-06 09:39:26.249709 RBA 2076
GGSCI (oggtarget.localdomain) 2> alter replicat rep_rev,extseqno 0,extrba 2076
REPLICAT altered.
GGSCI (oggtarget.localdomain) 3> start rep_rev
Sending START request to MANAGER ...
REPLICAT REP_REV starting
GGSCI (oggtarget.localdomain) 4> info rep_rev
REPLICAT REP_REV Last Started 2015-08-06 10:16 Status RUNNING
Checkpoint Lag 00:24:14(updated 00:00:03 ago)
Log Read Checkpoint File ./dirdat/tv000000
2015-08-06 09:51:59.256924 RBA 2429
(3)目标端再次查询,数据已同步,修复完成。
SQL> select * from ogg_user.test;
A
-----
11
111
222
22
附:也可以用Discardfile查询进程的错误信息
Discardfile在OGG的安装目录中dirrpt子目录中,后缀名为 .dsc
[root@oggtarget ~]# cd/home/goldengate/ogg/dirrpt
[root@ oggtarget dirrpt]# cat rep_rev.dsc
略过……
Current time: 2015-08-06 09:39:31
Discarded record from action ABEND on error12899
OCI Error ORA-12899: value too large forcolumn "OGG_USER"."TEST"."A" (actual: 3, maximum:2) (status = 12899). INSERT INTO "OGG_USER"."TEST"("A") VALUES (:a0)
Aborting transaction on ./dirdat/tvbeginning at seqno 0 rba 2076
error at seqno 0 rba2076
Problem replicating OGG_USER.TEST toOGG_USER.TEST
Mapping problem with insert record (targetformat)...
*
A = 111
*
Process Abending : 2015-08-06 09:39:31
Oracle GoldenGate Delivery for Oracleprocess started, group REP_REV discard file opened: 2015-08-06 10:16:11