goldengate 长事物处理方法



1、ggserr.log中提示长事物警告

2018-06-02 20:41:30  INFO    OGG-01021  Oracle GoldenGate Capture for Oracle, eora_1.prm:  Command received from GGSCI: showtrans thread 1 count 10.
2018-06-02 20:41:30  WARNING OGG-01742  Oracle GoldenGate Command Interpreter for Oracle:  Command sent to EXTRACT EORA_1 returned with an ERROR response.
2018-06-02 20:41:36  WARNING OGG-01027  Oracle GoldenGate Capture for Oracle, eora_1.prm:  Long Running Transaction: XID 8.32.5482, Items 1, Extract EORA_1, Redo Thread 1, SCN 0.23340272 (23340272), Redo Seq #37, Redo RBA 33959952.

2、查询抽取进程EORA_1的参数配置

GGSCI (qxy.localdomain) 169>   edit params EORA_1

-- Change Capture parameter file to capture
-- user1 and user2 changes
EXTRACT EORA_1
SETENV(NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD tiger
TRANLOGOPTIONS EXCLUDEUSER ogg
reportcount every 120 minutes, rate
report at 01:00
reportrollover at 01:15
threadoptions maxcommitpropagationdelay 30000
discardfile ./dirrpt/eora_1.dsc, append megabytes 100
discardrollover at 01:15
warnlongtrans 1m, checkinterval 1m
EXTTRAIL ./dirdat/aa
--ddl include all
--ddloptions addtrandata, report
TABLE scott.user1;
TABLE soctt.user2;

因为是为了测试,这里把warnlongtrans、checkinterval均设置为1分钟

3、查询长事物

select a.sid,
a.serial#,
a.user#,
a.username,
b.addr,
b.USED_UBLK,
b.USED_UREC,
b.START_TIME,
b.xidusn,
b.XIDSLOT,
 b.xidsqn
from v$transaction b, v$session a
where /*b.addr in (select a.taddr from v$session a where a.sid = '') and*/ b.addr=a.taddr order by start_time

      SID    SERIAL#      USER# USERNAME   ADDR              USED_UBLK  USED_UREC START_TIME               XIDUSN    XIDSLOT     XIDSQN
---------- ---------- ---------- ---------- ---------------- ---------- ---------- -------------------- ---------- ---------- ----------
       159         51         83 SCOTT      000000008BD1E698          1          1 06/02/18 19:55:24             8         32       
注:
     和ggserr日志中的信息一致。

4、使用ggsci命令检查长事物

GGSCI (qxy.localdomain) 170> info eora_1,showtrans
ERROR: SHOWTRANS is not a valid option.


GGSCI (qxy.localdomain) 171> info eora_1, showch

EXTRACT    EORA_1    Last Started 2018-06-02 20:09   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:01 ago)
Process ID           5414
Log Read Checkpoint  Oracle Redo Logs
                     2018-06-02 20:37:51  Seqno 46, RBA 67072
                     SCN 0.23341984 (23341984)


Current Checkpoint Detail:

Read Checkpoint #1

  Oracle Redo Log

  Startup Checkpoint (starting position in the data source):
    Thread #: 1
    Sequence #: 37
    RBA: 33953296
    Timestamp: 2018-06-02 19:54:47.000000
    SCN: 0.23340252 (23340252)
    Redo File: /u01/app/oradata/QXY/redo01.log

  Recovery Checkpoint (position of oldest unprocessed transaction in the data source):
    Thread #: 1
    Sequence #: 37
    RBA: 33959952
    Timestamp: 2018-06-02 19:55:26.000000
    SCN: 0.23340272 (23340272)
    Redo File: Not Available

  Current Checkpoint (position of last record read in the data source):
    Thread #: 1
    Sequence #: 46
    RBA: 67072
    Timestamp: 2018-06-02 20:37:51.000000
    SCN: 0.23341984 (23341984)
    Redo File: /u01/app/oradata/QXY/redo01.log

  BR Previous Recovery Checkpoint:
    Thread #: 0
    Sequence #: 0
    RBA: 0
    Timestamp: 2018-05-31 12:51:16.738698
    SCN: Not available
    Redo File: 

  BR Begin Recovery Checkpoint:
    Thread #: 1
    Sequence #: 21
    RBA: 18945536
    Timestamp: 2018-05-31 16:50:36.000000
    SCN: 0.21754129 (21754129)
    Redo File: 

  BR End Recovery Checkpoint:
    Thread #: 1
    Sequence #: 21
    RBA: 18945536
    Timestamp: 2018-05-31 16:50:36.000000
    SCN: 0.21754129 (21754129)
    Redo File: 

Write Checkpoint #1

  GGS Log Trail

  Current Checkpoint (current write position):
    Sequence #: 29
    RBA: 1595
    Timestamp: 2018-06-02 20:38:46.385699
    Extract Trail: ./dirdat/aa
    Trail Type: EXTTRAIL

Header:
  Version = 2
  Record Source = A
  Type = 10
  # Input Checkpoints = 1
  # Output Checkpoints = 1

File Information:
  Block Size = 2048
  Max Blocks = 100
  Record Length = 2048
  Current Offset = 0

Configuration:
  Data Source = 3
  Transaction Integrity = 1
  Task Type = 0

Status:
  Start Time = 2018-06-02 20:09:20
  Last Update Time = 2018-06-02 20:38:46
  Stop Status = A
  Last Result = 400
GGSCI (qxy.localdomain) 172> 

如果 current checkpoint 和Recovery Checkpoint  不一致,说明存在长事物

GGSCI (qxy.localdomain) 176> send extract eora_1 ,showtrans count 10  

Sending showtrans request to EXTRACT EORA_1 ...


Oldest redo log file necessary to restart Extract is:

Redo Log Sequence Number 37, RBA 33959952

------------------------------------------------------------
XID:                  8.32.5482             
Items:                1        
Extract:              EORA_1    
Redo Thread:          1      
Start Time:           2018-06-02:19:55:26  
SCN:                  0.23340272 (23340272)             
Redo Seq:             37
Redo RBA:             33959952            
Status:               Running             


GGSCI (qxy.localdomain) 177> 

4、查询事物的发起时间、状态,判断是否可以回滚或者提交

select t.start_time, t.xidusn||'.'||t.xidslot||'.'||t.xidsqn xid, s.status,
s.sid,s.serial#,s.username,s.status,s.schemaname,
decode(s.sql_id,null,s.prev_sql_id) sqlid, decode(s.sql_child_number,null,s.prev_child_number) child
from v$transaction t, v$session s
where s.saddr = t.ses_addr
order by t.start_time
START_TIME           XID        STATUS          SID    SERIAL# USERNAME   STATUS   SCHEMANAME                     SQLID              CHILD
-------------------- ---------- -------- ---------- ---------- ---------- -------- ------------------------------ ------------- ----------
06/02/18 19:55:24    8.32.5482  INACTIVE        159         51 SCOTT      INACTIVE SCOTT                          g73njsp71rfb0          0

5、其他处理办法

send extract ,skiptrans跳过事务(不建议)                                              
SEND EXTRACT <进程名>, SKIPTRANS <5.17.27634> THREAD <2> //跳过交易
 
send extract ,forcetrans强制认为事务已经提交(不建议)                                 
SEND EXTRACT <进程名>, FORCETRANS <5.17.27634> THREAD <1> //强制认为该交易已经提交                                                                                       

建议在数据库层提交或者回滚  

6、强制跳过事物

GGSCI (qxy.localdomain) 183> SEND EXTRACT EORA_1,SKIPTRANS 8.32.5482

Sending SKIPTRANS request to EXTRACT EORA_1 ...
Are you sure you sure you want to skip transaction [XID 8.32.5482, Redo Thread 1, Start Time 2018-06-02:19:55:26, SCN 0.23340272 (23340272)]? (y/n)y

Sending SKIPTRANS request to EXTRACT EORA_1 ...
Transaction [XID 8.32.5482, Redo Thread 1, Start Time 2018-06-02:19:55:26, SCN 0.23340272 (23340272)] skipped.


GGSCI (qxy.localdomain) 184> 
强制跳过,会导致OGG同步的时候,该事物丢失,对应的容灾库无法完成该事物会导致和生产库数据不一致。


你可能感兴趣的:(goldengate 长事物处理方法)