OGG 程式清除、重建

張衝andy發表於2017-03-05

背景描述:
有時候OGG程式同步出現問題,症狀某些程式起不來,而且問題一時半會兒解決不了。
最簡單的辦法是:用資料泵初始化資料,OGG程式重建。

1.檢視源端、目的端的程式狀態。 (作者OGG程式是正常的,假設程式是 abend )

源端:
GGSCI (11g) 1> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
EXTRACT RUNNING DPEA 00:00:00 00:00:08 
EXTRACT RUNNING EXTA 00:00:00 00:00:04

目的端:
GGSCI (11g) 1> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
REPLICAT RUNNING REPA 00:00:00 00:00:07

2. 停止 源端、目的端 除 mgr 程式,以外的所有ogg程式。

源端:

GGSCI (11g) 2> stop exta
Sending STOP request to EXTRACT EXTA ...
Request processed.

 


GGSCI (11g) 3> stop dpea
Sending STOP request to EXTRACT DPEA ...
Request processed.


目的端:

GGSCI (11g) 2> stop repa
Sending STOP request to REPLICAT REPA ...
Request processed.


3. 檢查源端、目的端 除 mgr 程式,以外的所有ogg程式的程式狀態是否是 stop。

源端:


GGSCI (11g) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
EXTRACT STOPPED DPEA 00:00:00 00:01:54 
EXTRACT STOPPED EXTA 00:00:00 00:02:07

目的端:

GGSCI (11g) 3> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
REPLICAT STOPPED REPA 00:00:00 00:01:32


4. 用OGG管理使用者連上資料庫,刪掉除 mgr 程式,以外的所有ogg程式。

源端:

GGSCI (11g) 5> dblogin userid goldengate,password goldengate
Successfully logged into database.

GGSCI (11g) 6> delete exta
Deleted EXTRACT EXTA.

GGSCI (11g) 7> delete dpea
Deleted EXTRACT DPEA.

目的端:

GGSCI (11g) 4> dblogin userid goldengate,password goldengate
Successfully logged into database.

GGSCI (11g) 5> delete repa
Deleted REPLICAT REPA.

5. 檢查ogg程式狀態。

源端:

GGSCI (11g) 8> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING

目的端:

GGSCI (11g) 6> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING

6. 清除引數 (注意刪除檔案的時候,不要多刪其他無關程式檔案)

源端:

[oracle@11g ogg]$ cd dirprm
[oracle@11g dirprm]$ pwd
/home/oracle/ogg/dirprm
[oracle@11g dirprm]$ ll
total 16
-rw-rw-rw-. 1 oracle oinstall 193 Nov 9 07:54 dpea.prm
-rw-rw-rw-. 1 oracle oinstall 206 Nov 9 07:53 exta.prm
-rwxr-x---. 1 oracle oinstall 53 Apr 23 2012 jagent.prm
-rw-rw-rw-. 1 oracle oinstall 10 Nov 9 03:52 mgr.prm
[oracle@11g dirprm]$ rm -rf dpea.prm exta.prm

目的端:

[oracle@11g ogg]$ cd dirprm
[oracle@11g dirprm]$ pwd
/home/oracle/ogg/dirprm
[oracle@11g dirprm]$ ll
total 12
-rwxr-x---. 1 oracle oinstall 53 Apr 23 2012 jagent.prm
-rw-rw-rw-. 1 oracle oinstall 10 Nov 9 03:53 mgr.prm
-rw-rw-rw-. 1 oracle oinstall 301 Nov 9 07:55 repa.prm
[oracle@11g dirprm]$ rm -rf repa.prm

7.清除 Trails 檔案

源端:
[oracle@11g dirprm]$ cd ..
[oracle@11g ogg]$ cd dirdat
[oracle@11g dirdat]$ pwd
/home/oracle/ogg/dirdat
[oracle@11g dirdat]$ ll
total 20
-rw-rw-rw-. 1 oracle oinstall 1023 Nov 9 06:57 la000000
-rw-rw-rw-. 1 oracle oinstall 1336 Nov 9 07:55 la000001
-rw-rw-rw-. 1 oracle oinstall 1212 Feb 1 04:10 la000002
-rw-rw-rw-. 1 oracle oinstall 1082 Feb 2 03:21 la000003
-rw-rw-rw-. 1 oracle oinstall 1082 Feb 2 03:21 la000004
[oracle@11g dirdat]$ rm -rf la*

目的端:
[oracle@11g ogg]$ cd dirdat
[oracle@11g dirdat]$ pwd
/home/oracle/ogg/dirdat
[oracle@11g dirdat]$ ll
total 16
-rw-rw-rw-. 1 oracle oinstall 1370 Nov 9 07:56 ra000000
-rw-rw-rw-. 1 oracle oinstall 1335 Feb 1 04:09 ra000001
-rw-rw-rw-. 1 oracle oinstall 1235 Feb 2 03:21 ra000002
-rw-rw-rw-. 1 oracle oinstall 1265 Feb 2 03:21 ra000003
[oracle@11g dirdat]$ rm -rf ra*


ok,至此舊OGG程式清除完畢。

以下是重新建立相關的ogg程式 :

1. 檢視 mgr 程式狀態,確保為 running

源端:

GGSCI (11g) 2> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING

目的端:

GGSCI (11g) 2> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING

2. 檢視 mgr 引數配置

源端:

GGSCI (11g) 3> view param mgr
port 7809

目的端:

GGSCI (11g) 3> view param mgr
port 7809

3. 建立ext程式,tail檔案,data_pump程式

源端:
GGSCI (11g) 11> add ext exta, tranlog, begin now
EXTRACT added.

GGSCI (11g) 12> add exttrail /home/oracle/ogg/dirdat/la, ext exta, MEGABYTES 20 -- 建立源trail檔案
EXTTRAIL added.

GGSCI (11g) 13> add extract dpea, EXTTRAILSOURCE /home/oracle/ogg/dirdat/la -- 建立data_pump程式
EXTRACT added.

GGSCI (11g) 14> add rmttrail /home/oracle/ogg/dirdat/ra, ext dpea, MEGABYTES 20 --建立目標端trail檔案
RMTTRAIL added.

GGSCI (11g) 15> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
EXTRACT STOPPED DPEA 00:00:00 00:02:48 
EXTRACT STOPPED EXTA 00:00:00 00:09:36

GGSCI (11g) 17> edit param exta --exta檔案新增內容顯示如下

GGSCI (11g) 35> view param exta

EXTRACT exta
setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
setenv (ORACLE_SID = orcl)
USERID goldengate, PASSWORD goldengate
EXTTRAIL /home/oracle/ogg/dirdat/la
dynamicresolution
table oggdemo.oggdemo;

GGSCI (11g) 33> start exta
Sending START request to MANAGER ...
EXTRACT EXTA starting

GGSCI (11g) 34> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
EXTRACT STOPPED DPEA 00:00:00 01:40:39 
EXTRACT RUNNING EXTA 01:47:26 00:00:01

GGSCI (11g) 36> edit param dpea --dpea檔案新增內容顯示如下

GGSCI (11g) 39> view param dpea

extract dpea
setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
passthru
rmthost 10.100.25.16,mgrport 7809, compress
rmttrail /home/oracle/ogg/dirdat/ra
dynamicresolution
table oggdemo.oggdemo;

引數說明:
passthru表示本程式是一個傳輸程式data pump,無需跟資料庫互動,只需要搬運資料即可;
因為data pump要傳輸資料到目標,所以需要配置rmthost和rmttrail指定目標主機和佇列資訊

GGSCI (11g) 37> start dpea
Sending START request to MANAGER ...
EXTRACT DPEA starting

GGSCI (11g) 38> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
EXTRACT RUNNING DPEA 00:00:00 00:00:00 
EXTRACT RUNNING EXTA 00:00:00 00:00:04

4. 建立目標資料庫的replicate程式

目的端:
GGSCI (11g) 6> add rep repa, exttrail /home/oracle/ogg/dirdat/ra, nodbcheckpoint
REPLICAT added.

引數說明: 
repa為程式名,一般為rep開頭表示是replicat程式,後面可以加1-2位字元標識,一般與ext程式對應;
exttrail表示要抽取的資料佇列,注意是目標端的佇列位置;
nodbcheckpoint表示不使用資料庫檢查點。

GGSCI (11g) 17> edit param repa -- repa檔案新增內容顯示如下

GGSCI (11g) 20> view param repa

replicat repa
setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK)
setenv (ORACLE_SID = orcl)
userid goldengate, password goldengate
reperror default,abend
discardfile /home/oracle/ogg/dirrpt/repa.dsc,append, megabytes 10
assumetargetdefs
dynamicresolution
map oggdemo.oggdemo, target oggdemo.oggdemo;

GGSCI (11g) 18> start repa
Sending START request to MANAGER ...
REPLICAT REPA starting

GGSCI (11g) 19> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING 
REPLICAT RUNNING REPA 00:00:00 00:00:01

5.DML資料測試

源端:

SQL> select * from oggdemo;
ID
----------
1
2

SQL> insert into oggdemo values(3);
1 row created.

SQL> commit;
Commit complete.

目標端:

SQL> select * from oggdemo;
ID
----------
1
2

SQL> select * from oggdemo;
ID
----------
1
2
3

ok,至此資料同步成功。 轉載請標明出處。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2134732/,如需轉載,請註明出處,否則將追究法律責任。

相關文章