Oracle 11g 測試ogg中斷之后,重新同步操作


測試ogg中斷之后,重新同步操作

2018-06-07 17:11 779 1 原創 GoldenGate

1.測試ogg中斷之后,重新同步操作

1.1.關閉源端抽取進程

GGSCI (cndba) 65> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     EXT1        00:00:00      00:00:09    
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:08    

GGSCI (cndba) 66> stop ext1
Sending STOP request to EXTRACT EXT1 ...
Request processed.

GGSCI (cndba) 67> stop pump1
Sending STOP request to EXTRACT PUMP1 ...
Request processed.

GGSCI (cndba) 68> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     STOPPED     EXT1        00:00:00      00:00:04    
EXTRACT     STOPPED     PUMP1       00:00:00      00:00:01

1.2.關閉目標端進程

GGSCI (cndba) 55> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    RUNNING     REP1        00:00:00      00:00:08  
GGSCI (cndba) 56> stop rep1
Sending STOP request to REPLICAT REP1 ...
Request processed.
GGSCI (cndba) 57> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    STOPPED     REP1        00:00:00      00:00:01

1.3.檢查源端,目標端表數據

--源端
SQL> select * from test1;
no rows selected
--目標端
SQL> select * from test1;
no rows selected

1.4.源端表插入100000條數據

記住插入之前的時間2018-06-07 16:15:24,這個時間點很重要,extract 進程要從這個時間開始抽取
SQL> insert into test1 select level,level||'t' from dual connect by level <= 100000;

100000 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from test1;

  COUNT(*)
----------
    100000
如果此時開啟源端extract進程,目標端replicat,數據同步不會出現問題,現在的操作就是:
1)結束當前的本地日志,重新開始一個日志
2)從當前新生成的序列重新抓取

1.5.源端操作

1.5.1.查看當前tail文件信息

[root@www.cndba.cn dirdat]# ll
total 12
drwxr-xr-x 2 root   root     4096 Jun  7 15:47 backup
-rw-rw-rw- 1 oracle oinstall 1405 Jun  7 16:11 et000000
-rw-rw-rw- 1 oracle oinstall 1016 Jun  7 16:19 et000001
可以看到當前tail文件是1號文件,重啟的時候會自動變成2號文件。

1.5.2.重新生成新的tail文件,抽取進程,投遞進程從新的tail文件開始抓取數據

GGSCI (cndba) 70> alter extract ext1 etrollover

2018-06-07 16:33:40  INFO    OGG-01520  Rollover performed.  For each affected output trail of Version 10 or higher format, after starting the source extract, issue ALTER EXTSEQNO for that trail's reader (either pump EXTRACT or REPLICAT) to move the reader's scan to the new trail file;  it will not happen automatically.
EXTRACT altered.

GGSCI (cndba) 71> alter extract ext1,thread 1,extseqno 2,extrba 0
EXTRACT altered.

GGSCI (cndba) 72> alter extract pump1 etrollover

2018-06-07 16:34:26  INFO    OGG-01520  Rollover performed.  For each affected output trail of Version 10 or higher format, after starting the source extract, issue ALTER EXTSEQNO for that trail's reader (either pump EXTRACT or REPLICAT) to move the reader's scan to the new trail file;  it will not happen automatically.
EXTRACT altered.

GGSCI (cndba) 73> alter extract pump1,thread 1,extseqno 2,extrba 0
EXTRACT altered.

1.5.3.源端從插入數據之前的時間開始抓取數據

GGSCI (cndba) 74> ALTER EXTRACT ext1, TRANLOG, BEGIN 2018-06-07 16:15:24
EXTRACT altered.

1.5.4.重啟源端進程

GGSCI (cndba) 58> start ext1

Sending START request to MANAGER ...
EXTRACT EXT1 starting


GGSCI (cndba) 59> start pump1

Sending START request to MANAGER ...
EXTRACT PUMP1 starting

GGSCI (cndba) 64> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     EXT1        00:00:00      00:00:06    
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:01

1.6.目標端操作

1.6.1.查看tail文件

可以看到目標端也生成了新的tail文件號,目標端從這個文件應用數據
[root@www.cndba.cn dirdat]# ll
total 21484
drwxr-xr-x 2 root   root         4096 Jun  7 15:48 backup
-rw-rw-rw- 1 oracle oinstall     1444 Jun  7 16:11 et000000
-rw-rw-rw- 1 oracle oinstall        0 Jun  7 16:19 et000001
-rw-rw-rw- 1 oracle oinstall 21989995 Jun  7 16:35 et000002

1.6.2.設置目標段讀取進程,從2號文件開始讀取

GGSCI (cndba) 74> alter REPLICAT rep1 extseqno 2, extrba 0
REPLICAT altered.


GGSCI (cndba) 75> start rep1

Sending START request to MANAGER ...
REPLICAT REP1 starting


GGSCI (cndba) 76> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
REPLICAT    RUNNING     REP1        00:00:00      00:00:04

1.6.3.檢查目標端數據

SQL> select count(1) from test1;

  COUNT(1)
----------
    100000

1.7.命令

--前滾重新生成一個新的隊列文件
alter extract xxx etrollover

--從指定時間重新抓取(重新抓取數據前提:歸檔文件沒有刪除)
ALTER EXTRACT xxx, TRANLOG, BEGIN 2010-12-31 08:00

--重置抽取進程,本地文件序列號從0開始生成。
alter extract ext1,extseqno 0,extrba 0

--重置讀取進程,重新從0號trial文件開始讀取。
alter replicat rep1,extseqno 0,extrba 0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM