GoldenGate配置(一)之單向複製配置

kunlunzhiying發表於2016-03-07

GoldenGate配置(一)之單向複製配置:

環境:

Item

Source System

Target System

Platform

Red Hat Enterprise

Linux Server release 5.4

Red Hat Enterprise

Linux Server release 5.4

Hostname

gc1

gc2

Database

Oracle 10.2.0.1

Oracle 11.2.0.1

Character Set

ZHS16GBK

ZHS16GBK

ORACLE_SID

PROD

EMREP

Listener Name/Port

LISTENER/1521

LISTENER/1521

Goldengate User

ogg

ogg

 

 


單向複製配置

gc1和gc2端需要配置的環境變數


export GG_HOME=/u01/app/ogg

export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/usr/bin:/lib

export PATH=$GG_HOME:$PATH

gc1:解壓GoldenGate安裝包

[oracle@gc1 ~]$ mkdir -p/u01/app/ogg

[oracle@gc1 ~]$ cd /u01/app/ogg

[oracle@gc1 ogg]$ ls

V18156-01-linux.zip

[oracle@gc1 ogg]$ unzip V18156-01-linux.zip

[oracle@gc1 ogg]$ tar -xvf ggs_redhatAS40_x86_ora10g_32bit_v10.4.0.19_002.tar

 

 

gc2:解壓GoldenGate安裝包

[oracle@gc2 ~]$ mkdir -p/u01/app/ogg

[oracle@gc2 ~]$ cd /u01/app/ogg

[oracle@gc2 ogg]$ ls

V18156-01-linux.zip

[oracle@gc2 ogg]$ unzip V18156-01-linux.zip

[oracle@gc2 ogg]$ tar -xvf ggs_redhatAS40_x86_ora10g_32bit_v10.4.0.19_002.tar

 

 

gc1:配置環境變數、建立相關子目錄

[oracle@gc1 ~]$ vi .bash_profile

新增

export GG_HOME=/u01/app/ogg

export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/usr/bin:/lib

export PATH=$GG_HOME:$PATH

[oracle@gc1~]$ source .bash_profile

[oracle@gc1ogg]$ ./ggsci

OracleGoldenGate Command Interpreter for Oracle

Version10.4.0.19 Build 002

Linux, x86,32bit (optimized), Oracle 10 on Sep 17 2009 23:49:42

 

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

GGSCI (gc1)1> create subdirs

 

Creatingsubdirectories under current directory /u01/app/ogg

 

Parameterfiles                /u01/app/ogg/dirprm: created

Reportfiles                  /u01/app/ogg/dirrpt: created

Checkpointfiles               /u01/app/ogg/dirchk:created

Process statusfiles           /u01/app/ogg/dirpcs:created

SQL scriptfiles               /u01/app/ogg/dirsql:created

Databasedefinitions files    /u01/app/ogg/dirdef: created

Extract datafiles             /u01/app/ogg/dirdat:created

Temporaryfiles                /u01/app/ogg/dirtmp:created

Veridatafiles                /u01/app/ogg/dirver: created

Veridata Lockfiles           /u01/app/ogg/dirver/lock: created

VeridataOut-Of-Sync files    /u01/app/ogg/dirver/oos: created

VeridataOut-Of-Sync XML files /u01/app/ogg/dirver/oosxml: created

VeridataParameter files      /u01/app/ogg/dirver/params: created

Veridata Reportfiles         /u01/app/ogg/dirver/report: created

Veridata Statusfiles         /u01/app/ogg/dirver/status: created

Veridata Tracefiles          /u01/app/ogg/dirver/trace: created

Stdoutfiles                   /u01/app/ogg/dirout:created

 

gc2:配置環境變數、建立相關子目錄

[oracle@gc2 ~]$ vi .bash_profile

新增

export GG_HOME=/u01/app/ogg

export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/usr/bin:/lib

export PATH=$GG_HOME:$PATH

[oracle@gc2~]$ source .bash_profile

[oracle@gc2db_1]$ cd $ORACLE_HOME/lib

[oracle@gc2lib]$ ln -s libnnz11.so libnnz10.so //可以暫不配置

[oracle@gc2ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 10.4.0.19 Build 002

Linux, x86, 32bit (optimized), Oracle 10 on Sep17 2009 23:49:42

 

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

GGSCI (gc2) 1> createsubdirs

 

Creating subdirectories under current directory/u01/app/ogg

 

Parameter files                /u01/app/ogg/dirprm: created

Report files                   /u01/app/ogg/dirrpt: created

Checkpoint files               /u01/app/ogg/dirchk: created

Process status files           /u01/app/ogg/dirpcs: created

SQL script files               /u01/app/ogg/dirsql: created

Database definitions files     /u01/app/ogg/dirdef: created

Extract data files             /u01/app/ogg/dirdat: created

Temporary files                /u01/app/ogg/dirtmp: created

Veridata files                 /u01/app/ogg/dirver: created

Veridata Lock files            /u01/app/ogg/dirver/lock: created

Veridata Out-Of-Sync files     /u01/app/ogg/dirver/oos: created

Veridata Out-Of-Sync XML files/u01/app/ogg/dirver/oosxml: created

Veridata Parameter files       /u01/app/ogg/dirver/params: created

Veridata Report files          /u01/app/ogg/dirver/report: created

Veridata Status files          /u01/app/ogg/dirver/status: created

Veridata Trace files           /u01/app/ogg/dirver/trace: created

Stdout files                   /u01/app/ogg/dirout: created

 

gc1:建立GoldenGate使用者、授權

[oracle@gc1~]$ mkdir -p /u01/app/oracle/oradata/soraeuc/

SQL>create tablespace tbs_gguser datafile'/u01/app/oracle/oradata/soraeuc/gguser.dbf' size 50M autoextend on;   --建立表空間

SQL>create user ogg identified by Ogg default tablespacetbs_gguser temporary tablespace TEMPTS quota unlimited on tbs_gguser;

SQL>grant CONNECT,RESOURCE to ogg;

SQL>grant CREATE SESSION, ALTER SESSION to ogg;

SQL>grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;

SQL>grant ALTER ANY TABLE to ogg;

SQL>grant FLASHBACK ANY TABLE to ogg;

SQL>grant EXECUTE on DBMS_FLASHBACK to ogg; 

SQL>@/u01/app/ogg/demo_ora_create    --建立模擬同步的表

Table dropped.

Table created.

Table dropped.

Table created.

SQL>@/u01/app/ogg/demo_ora_insert        --向模擬同步的表中插入資料

1 row created.

1 row created.

1 row created.

1 row created.

Commit complete.

SQL>select * from tcustmer;

CUST NAME                                                         CITY                 ST

------------------------------------------------------------------------------------ --

WILL BG SOFTWARE CO.                                             SEATTLE              WA

JANE ROCKY FLYER INC.                                            DENVER               CO

SQL>select * from tcustord;

CUST ORDER_DATE  PRODUCT_   ORDER_ID PRODUCT_PRICEPRODUCT_AMOUNT TRANSACTION_ID

---- ------------ -------- ----------------------- -------------- --------------

WILL 30-SEP-94   CAR             144         17520              3            100

JANE 11-NOV-95   PLANE           256        133300              1            100

 

gc2: 建立GoldenGate使用者、授權

[oracle@gc2~]$ mkdir -p /u01/app/oracle/oradata/soraeuc/

SQL>create tablespace tbs_gguser datafile'/u01/app/oracle/oradata/soraeuc/gguser.dbf' size 50M autoextend on;    --建立與源庫相同的表空間

SQL>create user ogg identified by Ogg default tablespacetbs_gguser temporary tablespace TEMPTS quota unlimited on tbs_gguser;

SQL>grant CONNECT, RESOURCE to ogg;

SQL>grant CREATE SESSION, ALTER SESSION to ogg;

SQL>grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;

SQL>grant CREATE TABLE to ogg;

SQL>conn scott/tiger

SQL>@/u01/app/ogg/demo_ora_create   --建立表,但不插入資料

Table dropped.

Table created.

Table dropped.

Table created.

SQL>grant INSERT, UPDATE, DELETE on scott.tcustmer to ogg; --把需要同步表的DML操作授權給ogg

SQL>grant INSERT, UPDATE, DELETE on scott.tcustord to ogg; --把需要同步表的DML操作授權給ogg

 

gc1:開啟補充日誌

SQL>select SUPPLEMENTAL_LOG_DATA_MIN from v$database;  --檢查源端是否開啟補充日誌

SUPPLEME

--------

NO

SQL>alter database add supplemental log data;   --開啟補充日誌

SQL>alter database add supplemental log data (primary key, unique,foreign key) columns;

--開啟主鍵、唯一鍵、外來鍵補充日誌

SQL>alter system switch logfile;               --切歸檔

 

gc1: 開啟歸檔

SQL>conn /as sysdba

SQL>alter system set log_archive_dest_1=' location=/u01/app/oracle/oradata/soraeuc/arch';

SQL>shutdown immediate

SQL>startup mount

SQL>alter database archivelog;

SQL>alter database open;

SQL>alter system archive log current; --檢查歸檔日誌資訊

SQL>archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination           /u01/app/oracle/oradata/soraeuc/arch

Oldest online log sequence     14

Next log sequence to archive   16

Current log sequence           16

 

gc1:開啟強制日誌模式

SQL>SELECT force_logging FROM v$database;  

FOR

---

NO

SQL>alter database force logging;        --開啟強制日誌模式

SQL>SELECT force_logging FROM v$database;

FOR

---

YES

 

gc1:開啟測試表補充日誌

[oracle@gc1ogg]$ ./ggsci

GGSCI(gc1) 1> DBLOGIN USERID ogg, PASSWORD Ogg

Successfully logged into database.

GGSCI(gc1) 2> ADD TRANDATA scott.TCUSTMER

Logging of supplemental redo data enabled fortable SCOTT.TCUSTMER.

GGSCI(gc1) 3> ADD TRANDATA scott.TCUSTORD

Logging of supplemental redo data enabled fortable SCOTT.TCUSTORD.

GGSCI(gc1) 4> INFO TRANDATA scott.TCUST*

Logging of supplemental redo log data is enabledfor table SCOTT.TCUSTMER

Logging of supplemental redo log data is enabledfor table SCOTT.TCUSTORD

 

gc1:配置MGR

[oracle@gc1ogg]$ ./ggsci

GGSCI(gc1) 1> EDIT PARAMS MGR              

新增如下:

PORT 7809

DYNAMICPORTLIST 7840-7890

AUTOSTART ER *

AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS ./dirdat/*,USECHECKPOINTS, MINKEEPDAYS 7 --建立dirdat資料夾用於追蹤

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45   

GGSCI(gc1) 2> START MGR

Manager started.

GGSCI(gc1) 3> INFO MGR    --驗證MGR已開啟

Manager is running (IP port gc1.7809).

 

gc2:配置MGR

[oracle@gc2ogg]$ ./ggsci

GGSCI(gc2) 1> EDIT PARAMS MGR

新增如下

PORT 7809

DYNAMICPORTLIST 7840-7890

AUTOSTART ER *

AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS ./dirdat/*,USECHECKPOINTS, MINKEEPDAYS 7 --建立dirdat資料夾用於追蹤

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

 

以下是MANAGER程式引數配置說明:

PORT指定服務監聽埠;這裡以7839為例,預設埠為7809

DYNAMICPORTLIST動態埠:可以制定最大256個可用埠的動態列表,當指定的埠不可用時,管理程式將會從列表中選擇一個可用的埠,源端和目標段的CollectorReplicatGGSCI程式通訊也會使用這些埠;

COMMENT註釋行,也可以用--來代替;

AUTOSTART指定在管理程式啟動時自動啟動哪些程式;

AUTORESTART自動重啟引數設定:本處設定表示每3分鐘嘗試重新啟動所有EXTRACT程式,共嘗試5次;

PURGEOLDEXTRACTS定期清理trail檔案設定:本處設定表示對於超過3天的trail檔案進行刪除。

LAGREPORTLAGINFOLAGCRITICAL

定義資料延遲的預警機制:本處設定表示MGR程式每隔1小時檢查EXTRACT的延遲情況,如果超過了30分鐘就把延遲作為資訊記錄到錯誤日誌中,如果延遲超過了45分鐘,則把它作為警告寫到錯誤日誌中。

GGSCI(gc2) 2> START MGR

Manager started.

GGSCI(gc2) 3> INFO MGR

Manager is running (IP port gc2.7809).

1.配置資料初始化

gc1:配置Extract程式

[oracle@gc1ogg]$ ./ggsci

GGSCI(gc1) 1> ADD EXTRACT EINI_1, SOURCEISTABLE

EXTRACT added.

GGSCI(gc1) 2> INFO EXTRACT *, TASKS

EXTRACT   EINI_1    Initialized   2014-06-18 09:54   Status STOPPED

Checkpoint Lag       Not Available

Log Read Checkpoint  Not Available

                     First Record         Record 0

Task                 SOURCEISTABLE

GGSCI(gc1) 3> EDIT PARAMS EINI_1

-- GoldenGate Initial Data Capture

-- for TCUSTMER and TCUSTORD

--

EXTRACT EINI_1

SETENV(NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD Ogg

RMTHOST gc2, MGRPORT 7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.TCUSTMER;

TABLE scott.TCUSTORD;

~

~

"dirprm/eini_1.prm" [New] 10L, 253Cwritten

EXTRACT程式引數配置說明:

SETENV配置系統環境變數

USERID/ PASSWORD指定OGG連線資料庫的使用者名稱和密碼,這裡使用3.4部分中建立的資料庫使用者OGG;

COMMENT註釋行,也可以用--來代替;

TABLE定義需複製的表,後面需以;結尾

TABLEEXCLUDE定義需要排除的表,如果在TABLE引數中使用了萬用字元,可以使用該引數指定排除掉得表。

GETUPDATEAFTERS|IGNOREUPDATEAFTERS

是否在佇列中寫入後影像,預設複製

GETUPDATEBEFORES| IGNOREUPDATEBEFORES

是否在佇列中寫入前影像,預設不復制

GETUPDATES|IGNOREUPDATES

是否複製UPDATE操作,預設複製

GETDELETES|IGNOREDELETES

是否複製DELETE操作,預設複製

GETINSERTS|IGNOREINSERTS

是否複製INSERT操作,預設複製

GETTRUNCATES|IGNORETRUNDATES

是否複製TRUNCATE操作,預設不復制;

RMTHOST指定目標系統及其GoldengateManager程式的埠號,還用於定義是否使用壓縮排行傳輸,本例中的compress為壓縮傳輸;

RMTTRAIL指定寫入到目標斷的哪個佇列;

EXTTRAIL指定寫入到本地的哪個佇列;

SQLEXECextract程式執行時首先執行一個SQL語句;

PASSTHRU禁止extract程式與資料庫互動,適用於Data Pump傳輸程式;

REPORT定義自動定時報告;

STATOPTIONS定義每次使用stat時統計數字是否需要重置;

REPORTCOUNT報告已經處理的記錄條數統計數字;

TLTRACE開啟對於資料庫日誌的跟蹤日誌;

DISCARDFILE定義discardfile檔案位置,如果處理中油記錄出錯會寫入到此檔案中;

DBOPTIONS指定對於某種特定資料庫所需要的特殊引數;

TRANLOGOPTIONS指定在解析資料庫日誌時所需要的特殊引數,例如:對於裸裝置,可能需要加入以下引數 rawdeviceoggset 0

WARNLONGTRANS指定對於超過一定時間的長交易可以在gsserr.log裡面寫入警告資訊,本處配置為每隔3分鐘檢查一次場交易,對於超過2小時的進行警告;

gc2:配置Replicat程式

[oracle@gc2ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 10.4.0.19 Build 002

Linux, x86, 32bit (optimized), Oracle 10 on Sep17 2009 23:49:42

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

GGSCI(gc2) 1> ADD REPLICAT RINI_1, SPECIALRUN

REPLICAT added.

GGSCI(gc2) 2> INFO REPLICAT *, TASKS

REPLICAT  RINI_1    Initialized   2014-06-18 10:03   Status STOPPED

Checkpoint Lag       00:00:00 (updated 00:00:09 ago)

Log Read Checkpoint  Not Available

Task                 SPECIALRUN

GGSCI(gc2) 3> EDIT PARAMS RINI_1

-- GoldenGate Initial Load Delivery

--

REPLICAT RINI_1

SETENV(NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)

ASSUMETARGETDEFS

USERID ogg, PASSWORD Ogg

DISCARDFILE ./dirrpt/RINIaa.dsc, PURGE

MAP scott.*, TARGET scott.*;

~

~

~

~

~

~

~

"dirprm/rini_1.prm" [New] 8L, 210Cwritten

REPLICAT程式引數配置說明:

ASSUMETARGETDEFS假定兩端資料結構一致使用此引數;

SOURCEDEFS假定兩端資料結構不一致,使用此引數指定源端的資料結構定義檔案,該檔案需要由GlodenGate工具產生。

MAP:用於指定源端與目標端表的對映關係;

MAPEXCLUDE用於使用在MAP中使用*匹配時排除掉指定的表;

REPERROR定義出錯以後程式的響應,一般可以定義為兩種:

ABEND,即一旦出現錯誤即停止複製,此為預設配置;

DISCARD,出現錯誤後繼續複製,只是把錯誤的資料放到discard檔案中。

DISCARDFILE定義discardfile檔案位置,如果處理中油記錄出錯會寫入到此檔案中;

SQLEXEC在程式執行時首先執行一個SQL語句;

GROUPTRANSOPS將小交易合併成一個大的交易進行提交,減少提交次數,降低系統IO消耗。

MAXTRANSOPS將大交易拆分,每XX條記錄提交一次。

gc1:開啟Extract程式(目標端Replicate程式會自動開啟)

GGSCI(gc1) 11> START EXTRACT EINI_1

Sending START request to MANAGER ...

EXTRACT EINI_1 starting

 

gc1:驗證資料載入

GGSCI(gc1) 12> VIEW REPORT EINI_1

2014-06-18 10:13:43  GGS INFO        414 Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is used.

......

......

Output to RINI_1:

From Table SCOTT.TCUSTMER:

      #                   inserts:         2

      #                   updates:         0

      #                   deletes:         0

      #                  discards:         0

From Table SCOTT.TCUSTORD:

      #                   inserts:         2

      #                   updates:         0

      #                   deletes:         0

      #                  discards:         0

 

gc2:驗證資料載入

GGSCI(gc2) 6> VIEW REPORT RINI_1

......

......

Report at 2014-06-18 10:13:57 (activity since2014-06-18 10:13:50)

 

From Table SCOTT.TCUSTMER to SCOTT.TCUSTMER:

      #                   inserts:         2

      #                   updates:         0

      #                   deletes:         0

      #                  discards:         0

From Table SCOTT.TCUSTORD to SCOTT.TCUSTORD:

      #                   inserts:         2

       #                   updates:         0

      #                   deletes:         0

      #                  discards:         0

 

gc2:確認初始化資料(由gc1傳輸而來)

SQL>conn scott/tiger

Connected.

SQL>select * from tcustmer;

CUST NAME                           CITY                 ST

---- -------------------------------------------------- --

WILL BG SOFTWARE CO.                SEATTLE              WA

JANE ROCKY FLYER INC.               DENVER               CO

SQL>set linesize 200

SQL>select * from tcustord

CUST ORDER_DATE  PRODUCT_   ORDER_ID PRODUCT_PRICEPRODUCT_AMOUNT TRANSACTION_ID

---- ------------ -------- ----------------------- -------------- --------------

WILL 30-SEP-94   CAR             144         17520              3            100

JANE 11-NOV-95   PLANE           256        133300              1            100

--從源端到目標端資料初始化成功

 

--資料初始完成後,源端Extract程式、目標端Replicat程式自動停止

gc1:檢查Extract程式狀態

GGSCI(gc1) 13> INFO EXTRACT EINI_1

EXTRACT   EINI_1    Last Started 2014-06-1810:13   Status STOPPED

Checkpoint Lag       Not Available

Log Read Checkpoint  Table SCOTT.TCUSTORD

                     2014-06-18 10:13:53  Record 2

Task                 SOURCEISTABLE

 

gc2:檢查Replicat程式狀態

GGSCI(gc2) 1> INFO REPLICAT RINI_1

REPLICAT  RINI_1    Initialized   2014-06-18 10:03   Status STOPPED

Checkpoint Lag       00:00:00 (updated 00:21:01 ago)

Log Read Checkpoint  Not Available

Task                 SPECIALRUN

2.實時同步資料配置 

gc1:配置Extract程式

GGSCI(gc1) 14> EDIT PARAMS EORA_1

-- Change Capture parameter file to capture

-- TCUSTMER and TCUSTORD changes

EXTRACT EORA_1

SETENV(NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

EXTTRAIL ./dirdat/aa

--ddl include all  --新增ddl支援

--ddloptions addtrandata, report --新增ddl支援

TABLE scott.TCUSTMER;

TABLE scott.TCUSTORD;

~

~

~

"dirprm/eora_1.prm" [New] 8L, 228Cwritten

GGSCI(gc1) 15> ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW

EXTRACT added.

GGSCI(gc1) 16> ADD EXTTRAIL ./dirdat/aa, EXTRACT EORA_1, MEGABYTES 5

EXTTRAIL added.

GGSCI(gc1) 17> START EXTRACT EORA_1

Sending START request to MANAGER ...

EXTRACT EORA_1 starting

GGSCI(gc1) 18> INFO EXTRACT EORA_1

EXTRACT   EORA_1    Last Started 2014-06-1810:29   Status RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:00 ago)

Log Read Checkpoint  Oracle Redo Logs

                     2014-06-18 10:29:19  Seqno 16, RBA 1328640

[oracle@gc1ogg]$ ll /u01/app/ogg/dirdat/   --驗證跟蹤檔案

total 4

-rw-rw-rw- 1 oracle oinstall 893 Jun 18 10:29 aa000000

 

gc1:配置Pump程式

GGSCI(gc1) 1> EDIT PARAMS PORA_1

-- Data Pump parameter file to read the local

-- trail of TCUSTMER and TCUSTORD changes

--

EXTRACT PORA_1

SETENV(NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)

PASSTHRU

RMTHOST gc2, MGRPORT 7809

RMTTRAIL ./dirdat/pa

TABLE scott.TCUSTMER;

TABLE scott.TCUSTORD;

~

~

"dirprm/pora_1.prm" [New] 10L, 253Cwritten

GGSCI(gc1) 2> ADD EXTRACT PORA_1, EXTTRAILSOURCE ./dirdat/aa

EXTRACT added.

GGSCI(gc1) 3> INFO EXTRACT PORA_1

EXTRACT   PORA_1    Initialized   2014-06-18 10:35   Status STOPPED

Checkpoint Lag       00:00:00 (updated 00:00:14 ago)

Log Read Checkpoint  File ./dirdat/aa000000

                     First Record  RBA 0

GGSCI(gc1) 4> ADD RMTTRAIL ./dirdat/pa, EXTRACT PORA_1, MEGABYTES 5

RMTTRAIL added.

GGSCI(gc1) 5> START EXTRACT PORA_1

Sending START request to MANAGER ...

EXTRACT PORA_1 starting

GGSCI(gc1) 6> INFO EXTRACT PORA_1

EXTRACT   PORA_1    Last Started 2014-06-1810:36   Status RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:04 ago)

Log Read Checkpoint  File ./dirdat/aa000000

                     First Record  RBA 0

 

gc2:驗證gc1Pump程式配置

[oracle@gc2ogg]$ ll dirdat/    

total 0

-rw-rw-rw- 1 oracle oinstall 0 Jun 18 10:36pa000000

 

gc2:配置Checkpoint

GGSCI(gc2) 1> EDIT PARAMS ./GLOBALS

CHECKPOINTTABLE ogg.ggschkpt

~

"./GLOBALS" [New] 1L, 29C written

[oracle@gc2ogg]$ ll GLOBALS                           --檢查引數已新增

-rw-rw-rw- 1 oracle oinstall 29 Jun 18 10:42GLOBALS

GGSCI(gc2) 1> DBLOGIN USERID ogg, PASSWORD ogg

Successfully logged into database.

GGSCI(gc2) 2> ADD CHECKPOINTTABLE

No checkpoint table specified, using GLOBALSspecification (ogg.ggschkpt)...

Successfully created checkpoint tableOGG.GGSCHKPT.

 

gc2:配置Replicat程式

GGSCI(gc2) 3> ADD REPLICAT RORA_1, EXTTRAIL ./dirdat/pa

REPLICAT added.

GGSCI(gc2) 4> EDIT PARAM RORA_1

--

-- Change Delivery parameter file to apply

-- TCUSTMER and TCUSTORD Changes

--

REPLICAT RORA_1

SETENV(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

HANDLECOLLISIONS

ASSUMETARGETDEFS

DISCARDFILE ./dirrpt/RORA_aa.DSC, PURGE

--DDL INCLUDE ALL--新增ddl支援

--DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5--新增ddl支援

--DDLERROR DEFAULT DISCARD--新增ddl支援

--DDLERROR DEFAULT IGNORE RETRYOP--新增ddl支援

MAP scott.tcustmer, TARGET scott.tcustmer;

MAP scott.tcustord, TARGET scott.tcustord;

~

~

~

"dirprm/rora_1.prm" [New] 12L, 327Cwritten

GGSCI(gc2) 5> START REPLICAT RORA_1

Sending START request to MANAGER ...

REPLICAT RORA_1 starting

GGSCI(gc2) 6> INFO REPLICAT RORA_1

REPLICAT  RORA_1    Last Started 2014-06-1810:48   Status RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:07 ago)

Log Read Checkpoint  File ./dirdat/pa000000

                     First Record  RBA 0

 

gc1: DML操作:insert

SQL>conn scott/tiger

Connected.

SQL>insert into tcustmer VALUES('HYL','HUANGCO.','BEIJING','AU');

1 row created.

SQL>commit;

Commit complete.

 

gc2:驗證insert操作是否同步

SQL>conn scott/tiger

Connected.

SQL>select * from tcustmer;

CUST NAME                           CITY                 ST

---- -------------------------------------------------- --

HYL  HUANGCO.                      BEIJING              AU

WILL BG SOFTWARE CO.                SEATTLE              WA

JANE ROCKY FLYER INC.               DENVER               CO

 

gc1:DML操作:update

SQL>update tcustmer set city = 'SHANGHAI', state = 'CN' wherecust_code='HYL';

1 row updated.

SQL>commit;

Commit complete

gc2:驗證update操作是否同步

SQL>select * from tcustmer;

CUST NAME                           CITY                 ST

---- ------------------------------ ----------------------

HYL  HUANGCO.                      SHANGHAI             CN

WILL BG SOFTWARE CO.                SEATTLE              WA

JANE ROCKY FLYER INC.               DENVER               CO

 

gc1:DML操作:delete

SQL>delete from tcustmer where CUST_CODE='HYL';

1 row deleted.

SQL>commit;

Commit complete.

 

gc2:驗證delete操作是否同步

SQL>select * from tcustmer;

CUST NAME                           CITY                 ST

---- -------------------------------------------------- --

WILL BG SOFTWARE CO.                SEATTLE              WA

JANE ROCKY FLYER INC.               DENVER               CO

 

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

相關文章