GoldenGate的安裝、配置與測試

hooca發表於2015-01-26
環境:Oracle Linux 5.8/Windows Server 2003 +  Oracle Database 11.2.0.4 + Golengate 11.2

解壓安裝檔案裡的內容到/opt/goldengate,然後建立工作目錄:


點選(此處)摺疊或開啟

  1. [oracle@oltp ~]$ cd /opt/goldengate/
  2. [oracle@oltp goldengate]$ ggsci

  3. Oracle GoldenGate Command Interpreter for Oracle
  4. Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
  5. Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

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



  7. GGSCI (oltp.demo.com) 1> create subdirs

  8. Creating subdirectories under current directory /opt/goldengate

  9. Parameter files /opt/goldengate/dirprm: already exists
  10. Report files /opt/goldengate/dirrpt: created
  11. Checkpoint files /opt/goldengate/dirchk: created
  12. Process status files /opt/goldengate/dirpcs: created
  13. SQL script files /opt/goldengate/dirsql: created
  14. Database definitions files /opt/goldengate/dirdef: created
  15. Extract data files /opt/goldengate/dirdat: created
  16. Temporary files /opt/goldengate/dirtmp: created
  17. Stdout files /opt/goldengate/dirout: created

在Windows環境下,需要將manager程式新增到Windows服務,否則登出後程式就會退出

點選(此處)摺疊或開啟

  1. GGSCI (hum-cf0bf98919e) 2> EDIT PARAMS ./GLOBALS
  2. --編輯以下文字
  3. MGRSERVNAME GGMGR

  4. GGSCI (hum-cf0bf98919e) 4> exit

  5. C:\goldengate>install addservice

  6. Service 'GGMGR' created.


  7. Install program terminated normally.

--如果要刪除服務,進入根目錄後


C:\goldengate>install deleteevents deleteservice


Service 'GGMGR' removed.




Install program terminated normally.


二、資料庫設定

資料庫要設定為歸檔模式、並開啟資料庫級別的補充日誌,以及設定啟用GoldenGate複製的引數

點選(此處)摺疊或開啟

  1. SQL> select supplemental_log_data_min from v$database;

  2. SUPPLEMENTAL_LOG
  3. ----------------
  4. NO

  5. SQL> alter database add supplemental log data;

  6. Database altered.

  7. SQL> select supplemental_log_data_min from v$database;

  8. SUPPLEMENTAL_LOG
  9. ----------------
  10. YES
  --以下引數在11.2.1.0.26下必須改,否則extract程式無法啟動
  1. SQL> alter system set enable_goldengate_replication=TRUE scope=both;


    System altered.

建立使用者並賦予許可權:


點選(此處)摺疊或開啟

  1. --建立專屬表空間
  2. create tablespace ogg datafile size 100M autoextend on;
  3. --源和目的都執行
  4. create user ggs identified by ggs default tablespace ogg temporary tablespace temp;
  5. grant connect, resource, unlimited tablespace to ggs;
  6. grant execute on utl_file to ggs;

  7. --源端執行
  8. grant connect,resource to ggs;
  9. grant select any dictionary,select any table to ggs;
  10. grant alter any table to ggs;
  11. grant flashback any table to ggs;
  12. grant execute on DBMS_FLASHBACK to ggs;

  13. --目的端執行
  14. grant insert any table to ggs;
  15. grant delete any table to ggs;
  16. grant update any table to ggs;

  17. --如果不講究,可以直接給DBA許可權
  18. grant dba to ggs;
在trandata新增需要同步的表和schema

源端進入GGSCI

點選(此處)摺疊或開啟

  1. dblogin userid ggs,password ggs
  2. GGSCI (oltp.demo.com) 3> add trandata soe.*


    2015-01-26 21:43:25  WARNING OGG-00869  No unique key is defined for table 'ADDRESSES'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.ADDRESSES.


    2015-01-26 21:43:27  WARNING OGG-00869  No unique key is defined for table 'CARD_DETAILS'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.CARD_DETAILS.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'CUSTOMERS'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.CUSTOMERS.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'INVENTORIES'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.INVENTORIES.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'LOGON'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.LOGON.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'ORDERENTRY_METADATA'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.ORDERENTRY_METADATA.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'ORDERS'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.ORDERS.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'ORDER_ITEMS'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.ORDER_ITEMS.


    Logging of supplemental redo data enabled for table SOE.PRODUCT_DESCRIPTIONS.


    Logging of supplemental redo data enabled for table SOE.PRODUCT_INFORMATION.


    2015-01-26 21:43:28  WARNING OGG-00869  No unique key is defined for table 'WAREHOUSES'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.


    Logging of supplemental redo data enabled for table SOE.WAREHOUSES.

目標端新增checkpoint表


點選(此處)摺疊或開啟

  1. GGSCI (hum-cf0bf98919e) 1> edit params ./GLOBALS

  2. --新增一行
  3. checkpointtable ggs.checkpoint

  4. GGSCI (hum-cf0bf98919e) 2> dblogin userid ggs,password ggs
  5. Successfully logged into database.

  6. GGSCI (hum-cf0bf98919e) 3> add checkpointtable ggs.checkpoint

  7. Successfully created checkpoint table ggs.checkpoint.

  8. GGSCI (hum-cf0bf98919e) 4>

三、 GG程式

編輯並啟動源端Manager程式


點選(此處)摺疊或開啟

  1. GGSCI (oltp.demo.com) 5> edit params mgr
  2. port 7500
  3. dynamicportlist 7501-7505
  4. autorestart extract *,waitminutes 2,retries 5

  5. GGSCI (oltp.demo.com) 6> view params mgr

  6. port 7500
  7. dynamicportlist 7501-7505
  8. autorestart extract *,waitminutes 2,retries 5


  9. GGSCI (oltp.demo.com) 7> start mgr

  10. Manager started.
配置Extract程式組

建立名為eora的Extract程式組


點選(此處)摺疊或開啟

  1. GGSCI (oltp.demo.com) 8> edit params eora
  2. extract eora
  3. dynamicresolution
  4. userid ggs,password ggs
  5. exttrail /opt/goldengate/dirdat/et
  6. table soe.*;

  7. GGSCI (oltp.demo.com) 9add extract eora,tranlog,begin now
    1. EXTRACT added.

  8. GGSCI (oltp.demo.com) 11> add exttrail /opt/goldengate/dirdat/et,extract eora
  9. EXTTRAIL added.


  10. GGSCI (oltp.demo.com) 12> start extract eora


    Sending START request to MANAGER ...
    EXTRACT EORA starting


源端配置Pump程式組

點選(此處)摺疊或開啟

  1. GGSCI (oltp.demo.com) 19> edit params pump_so
  2. extract pump_so
  3. dynamicresolution
  4. passthru
  5. rmthost 192.168.226.13,mgrport 7809,compress
  6. rmttrail C:\goldengate\dirdat\pt
  7. table soe.*;

  8. GGSCI (oltp.demo.com) 20> add extract pump_so,exttrailsource /opt/goldengate/dirdat/et
  9. EXTRACT added.


  10. GGSCI (oltp.demo.com) 21> add rmttrail C:\goldengate\dirdat\pt,extract pump_so
  11. RMTTRAIL added.
  12. GGSCI (oltp.demo.com) 24> start pump_so


    Sending START request to MANAGER ...
    EXTRACT PUMP_SO starting




    GGSCI (oltp.demo.com) 25> info all


    Program     Status      Group       Lag at Chkpt  Time Since Chkpt


    MANAGER     RUNNING                                           
    EXTRACT     RUNNING     EORA        00:00:00      00:00:08    
    EXTRACT     RUNNING     PUMP_SO     00:00:00      00:21:32    



配置目的端MGR

點選(此處)摺疊或開啟

  1. GGSCI (hum-cf0bf98919e) 5> view params mgr
  2. port 7809
  3. dynamicportlist 7800-8000
  4. autostart er *
  5. autorestart extract *,waitminutes 2,retries 5
  6. lagreporthours 1
  7. laginfominutes 3
  8. lagcriticalminutes 5
  9. purgeoldextracts c:\goldengate\dirdat\rt*,usecheckpoints,minkeepdays 3


  10. GGSCI (hum-cf0bf98919e) 6> start mgr

  11. Starting Manager as service ('GGMGR')...
  12. Service started.


  13. GGSCI (hum-cf0bf98919e) 7> info all

  14. Program Status Group Lag at Chkpt Time Since Chkpt

  15. MANAGER RUNNING
配置目的端Replicate程式

點選(此處)摺疊或開啟

  1. GGSCI (hum-cf0bf98919e) 8> edit params repl


  2. GGSCI (hum-cf0bf98919e) 9> view params repl
  3. replicat repl
  4. userid ggs, password ggs
  5. assumetargetdefs
  6. reperror default,discard
  7. discardfile ./dirrpt/repl.dsc,append,megabytes 50
  8. dynamicresolution
  9. map soe.*, target soe.*;

  10. GGSCI (hum-cf0bf98919e) 11> add replicat repl,exttrail c:\goldengate\dirdat\pt checkpointtable ggs.checkpoint
  11. REPLICAT added.

  12. GGSCI (hum-cf0bf98919e) 12> start repl


    Sending START request to MANAGER ('GGMGR') ...
    REPLICAT REPL starting


程式狀態不正常時,檢視錯誤日誌,檔名是ggserr.log,在程式根目錄下。






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

相關文章