GoldenGate<一> step by step installation and configuration

viadeazhu發表於2010-04-14

    最近研究GoldenGate,此文記錄入門第一步--如何安裝。這裡的作業系統為Solaris 10 64bit。

    大家可以先從這裡下載各種文件:

    1. 根據作業系統和資料庫版本下載相應GG版本。下載地址:

由於我的機器是Solaris 10 64bit的,所以下載的檔案為Oracle GoldenGate v10.4.0.x for Oracle 10g 64bit on Solaris 10 (53 MB)。

到相應目錄解壓。

    2. 設定環境變數PATH和LD_LIBRARY_PATH

我在c shell下建立一個檔案.gg,執行source .gg即可。
setenv PATH :$PATH
setenv LD_LIBRARY_PATH :$LD_LIBRARY_PATH

    3. 目錄安裝

在GG的安裝目錄下,執行如下命令:

./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 10.4.0.19 Build 002
Solaris, sparc, 64bit (optimized), Oracle 10 on Sep 23 2009 15:19:42

Copyright (C) 1995, 2009, Oracle and/or its affiliates.  All rights reserved.

 

GGSCI (xxx) 1> CREATE SUBDIRS

Creating subdirectories under current directory /xxx

Parameter files                /xxx/dirprm: created
Report files                   /xxx/dirrpt: created
Checkpoint files               /xxx/dirchk: created
Process status files           /xxx/dirpcs: created
SQL script. files               /xxx/dirsql: created
Database definitions files     /xxx/dirdef: created
Extract data files             /xxx/dirdat: created
Temporary files                /xxx/dirtmp: created
Veridata files                 /xxx/dirver: created
Veridata Lock files            /xxx/dirver/lock: created
Veridata Out-Of-Sync files     /xxx/dirver/oos: created
Veridata Out-Of-Sync XML files /xxx/dirver/oosxml: created
Veridata Parameter files       /xxx/dirver/params: created
Veridata Report files          /xxx/dirver/report: created
Veridata Status files          /xxx/dirver/status: created
Veridata Trace files           /xxx/dirver/trace: created
Stdout files                   /xxx/dirout: created

    4. DDL support安裝

建立一個專為GGS DDL安裝的Oracle user,並賦予相應許可權:

SQL> create user ggs identified by ggs;

User created.

SQL> grant connect,resource to ggs;

Grant succeeded.

SQL> GRANT EXECUTE ON UTL_FILE TO ggs;

Grant succeeded.

SQL> GRANT SELECT ANY DICTIONARY TO ggs;

Grant succeeded.

SQL> GRANT SELECT ANY TABLE TO ggs;

Grant succeeded.

由於GGS_DDL_HIST和GGS_MARKER會持續增長,所以最好單獨建立一個tablespace給他們:

SQL> alter user ggs default tablespace GGSTBS;

User altered.

SQL> alter user ggs quota unlimited on GGSTBS;

User altered.

    5.  開啟Oracle supplemental log

SQL> select supplemental_log_data_min from v$database;

SUPPLEME
--------
NO


SQL> alter database add supplemental log data;


Database altered.

   6. 啟動Manager

在GGS安裝目錄下:

> ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 10.4.0.19 Build 002
Solaris, sparc, 64bit (optimized), Oracle 10 on Sep 23 2009 15:19:42

Copyright (C) 1995, 2009, Oracle and/or its affiliates.  All rights reserved.

 

GGSCI (xxx) 1> EDIT PARAMS MGR


PORT 7809
~
"dirprm/mgr.prm" [New File] 1 line, 10 characters written

GGSCI (xxx) 2> start mgr

Manager started.

GGSCI (qadb120) 3> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING  

注:以上步驟需要在Source和Target都執行。

    7. 在Source新增Extract Group

首先登入Source的Schema,新增EXTRACT程式和放在Target的TRAIL檔案地址

GGSCI (xxx) 1> DBLOGIN USERID , PASSWORD GGS
Successfully logged into database.

GGSCI (xxx) 2> add EXTRACT HAOEXT, tranlog,begin now
EXTRACT added.


GGSCI (xxx) 3> add RMTTRAIL ./dirdat/zh, extract  HAOEXT,  megabytes 50
RMTTRAIL added.


GGSCI (xxx) 4> info EXTRACT HAOEXT

EXTRACT    HAOEXT    Initialized   2010-04-21 09:43   Status STOPPED
Checkpoint Lag       00:00:00 (updated 00:00:23 ago)
Log Read Checkpoint  Oracle Redo Logs
                     2010-04-21 09:43:39  Seqno 0, RBA 0

新增EXTRACT的parameter file,然後啟動EXTRACT

GGSCI (xxx) 9> edit param HAOEXT


EXTRACT HAOEXT
SETENV (ORACLE_SID=MOT)
USERID
, PASSWORD GGS
RMTHOST xxx.xxx.xxx.xxx, MGRPORT 7809
RMTTRAIL ./dirdat/zh
TABLE HAOZHU_USER.GG1;
~
"dirprm/haoext.prm" [New File] 6 lines, 161 characters written


GGSCI (xxx) 10> start EXTRACT HAOEXT

Sending START request to MANAGER ...
EXTRACT HAOEXT starting

GGSCI (xxx) 12> info EXTRACT HAOEXT

EXTRACT    HAOEXT    Last Started 2010-04-21 10:19   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:02 ago)
Log Read Checkpoint  Oracle Redo Logs
                     2010-04-21 10:20:01  Seqno 59, RBA 157803008

    8. 在Target端新增Replicat Group

先新增引數

GGSCI (xxx) 1> edit params mgr


PORT 7809
~
"dirprm/mgr.prm" 2 lines, 27 characters written

再新增REPLICAT Group

GGSCI (xxx) 5> add replicat HAOREP, EXTTRAIL ./dirdat/zh, nodbcheckpoint
REPLICAT added.


GGSCI (xxx) 6> edit param HAOREP


REPLICAT HAOREP
ASSUMETARGETDEFS
SETENV (ORACLE_SID=DC1)
USERID GGS, PASSWORD GGS
map HAOZHU_USER.GG1 , target HAOZHU_USER.GG2;
~
"dirprm/haorep.prm" 5 lines, 128 characters written


GGSCI (xxx) 7> start REPLICAT HAOREP

Sending START request to MANAGER ...
REPLICAT HAOREP starting


GGSCI (qadb121) 8> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING                                          
REPLICAT    RUNNING     HAOREP      00:00:00      00:00:01
   

注意:在EDIT PARAMS 的時候,一定要加上最後的逗號,否則會報如下錯,我就在這搞了很久。。

2010-04-21 12:30:45  GGS ERROR       101  Oracle GoldenGate Delivery for Oracle, haorep.prm:  Parameter unterminated.
2010-04-21 12:30:45  GGS ERROR       190  Oracle GoldenGate Delivery for Oracle, haorep.prm:  PROCESS ABENDING.

    9. 測試複製

首先在Source檢測EXTRACT沒有任何資訊:

GGSCI (xxx) 5> stats HAOEXT

Sending STATS request to EXTRACT HAOEXT ...

No active extraction maps.

在Source插入一行但不commit:

SQL> insert into gg1(OBJECT_ID,OBJECT_NAME) values(20122012,'test by hao');

1 row created.

這時,如預期,沒有commit的資訊不會被抓取:

GGSCI (xxx) 6> stats HAOEXT

Sending STATS request to EXTRACT HAOEXT ...

No active extraction maps.

但commit之後:

SQL> commit;

Commit complete.

就有EXTRACT的資料了:

GGSCI (xxx) 7> stats HAOEXT

Sending STATS request to EXTRACT HAOEXT ...

Start of Statistics at 2010-04-21 12:58:23.

Output to ./dirdat/zh:

Extracting from HAOZHU_USER.GG1 to HAOZHU_USER.GG1:

*** Total statistics since 2010-04-21 12:58:07 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Daily statistics since 2010-04-21 12:58:07 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Hourly statistics since 2010-04-21 12:58:07 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Latest statistics since 2010-04-21 12:58:07 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

End of Statistics.

REPLICAT也有相應資料:

GGSCI (xxx) 1> stats haorep

Sending STATS request to REPLICAT HAOREP ...

Start of Statistics at 2010-04-21 13:05:51.

Replicating from HAOZHU_USER.GG1 to HAOZHU_USER.GG2:

*** Total statistics since 2010-04-21 12:58:10 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Daily statistics since 2010-04-21 12:58:10 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Hourly statistics since 2010-04-21 13:00:00 ***

        No database operations have been performed.

*** Latest statistics since 2010-04-21 12:58:10 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

End of Statistics.

複製成功:

SQL> select OBJECT_ID,OBJECT_NAME from gg2 where OBJECT_ID=20122012;

 OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------
  20122012
test by hao

【由此想到的問題:】

對於這種最簡單的配置,是由Source端的EXTRACT程式直接寫Target端的trail檔案,但如果網路出現問題,就會對Source端產生問題。

我實驗在Target端stop replicat and mgr,發現Traget的trail檔案仍被寫入。

> fuser zh000000
zh000000:    11482o
> ptree  11482
18089 zsched
  11482 ./server -p 7840 -k -l /xxx/ggserr.log

 於是kill -9 11482。

這時我再在Source端產生一點dml,結果發現此時Source端的EXTRACT程式死了。

GGSCI (xxx) 14> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING                                          
EXTRACT     ABENDED     HAOEXT      00:00:00      00:02:18
   

然後在ggserr.log中我們發現有146 error:

2010-04-22 03:48:54  GGS WARNING     150  Oracle GoldenGate Capture for Oracle, haoext.prm:  TCP/IP error 146 (Connection refused).

如何恢復?

首先在Target start mgr and replicat,然後在Source start extract。一切恢復正常。

但你會發現stats命令重新計數了:

GGSCI (xxx) 20> stats HAOEXT

Sending STATS request to EXTRACT HAOEXT ...

Start of Statistics at 2010-04-22 03:54:01.

Output to ./dirdat/zh:

Extracting from HAOZHU_USER.GG1 to HAOZHU_USER.GG1:

*** Total statistics since 2010-04-22 03:53:47 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Daily statistics since 2010-04-22 03:53:47 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Hourly statistics since 2010-04-22 03:53:47 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

*** Latest statistics since 2010-04-22 03:53:47 ***
        Total inserts                                1.00
        Total updates                                0.00
        Total deletes                                0.00
        Total discards                               0.00
        Total operations                             1.00

End of Statistics.

所以我個人比較偏向於再在Source端配置一個data pump程式,用來專門負責網路傳輸。

而由EXTRACT程式抓出來的資訊,先存放在本地的trail檔案裡。

這樣,就和shareplex的capture queue是異曲同工了。

待續。。

 

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

相關文章