OGG安裝及單向配置

君落塵發表於2014-08-21

    GoldenGate技術架構圖


     

    從圖中可以看到:GoldenGate主要包含Manager程式、Extract程式、Pump程式、Replicat程式,下面對其一一說明:

    Manager程式是GoldenGate的控制程式,它主要作用有以下幾個方面:啟動、監控、重啟GoldenGate的其他程式,報告錯誤及時間,分配資料儲存空間,釋出閥值報告等。

    Extract程式執行在資料庫源端,負責從源端資料表或日誌中捕獲資料。Extract程式利用其內在的checkpoint機制,週期性地檢查並記錄其讀寫的位置,通常是寫入到本地的trail檔案。這種機制是為了保證如果Extract程式終止或者作業系統當機,我們重啟Extract程式後,GoldenGate能夠恢復到以前的狀態,從上一個斷點處繼續往下執行,而不會有任何資料損失。

    Pump程式執行在資料庫源端,其作用非常簡單。如果源端使用了本地trail檔案,那麼Pump程式就會把Trail檔案以資料塊的形式透過TCP/IP協議傳送到目標端,我們下面的配置都是這種方式。Pump程式本質是Extract程式的一種特殊形式,如果不使用Trail檔案,那麼Extract程式在抽取完資料後,直接投遞到目標端。

    與Pump程式相對應的叫Server Collector程式,這個程式不需要引起我們關注,因為在實際操作過程中無需對其進行任何配置,它執行在目標端,任務就是把Extract/Pump程式投遞過來的資料塊重新組裝成Trail檔案。

    Replicat程式執行在目標端,是資料投遞的最後一站,負責讀取目標端Trail檔案中的內容,並將解析其解析為DML或DDL語句,然後應用到目標資料庫中。

    注:以上內容為轉載,加強對ogg理解。 

    [實施目的]

    1、OGG安裝及單向配置

     [專案環境]

    source system(gc1)

    作業系統

    RedHat 5.4

    主機名

    GC1

    資料庫版本

    Oracle 10.2.0.1.0

    字符集

    ZHS16GBK

    生產庫例項名

    PROD

    監聽

    LISTENER/1521

    target system(gc5)

    作業系統

    RedHat 5.4

    主機名

    GC5

    資料庫版本

    Oracle 10.2.0.1.0

    字符集

    ZHS16GBK

    生產庫例項名

    EMREP

    監聽

    LISTENER/1521

    [實施步驟]

  1. 在oracle使用者環境變數中增加以下一行

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib

新增後

[oracle@gc1 ~]$ source .bash_profile

  1. 安裝Goldengate 10 到伺服器

1)source system(gc1)

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

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

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

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

2)target system(gc5)

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

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

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

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

  1. Create sub working directories for Goldengate  

both Source system and Target system

[oracle@gc1 ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 10.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

 

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

  1. 在Source system and Target system建立Goldengate user並授權

1)Source system

[oracle@gc1 ogg]$ !sql

sqlplus '/as sysdba'

SQL> create tablespace tbs_gguser datafile '/u01/app/oracle/oradata/torautf/gguser.dbf' size 50M autoextend on;

SQL> create user ogg identified by ogg default tablespace tbs_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> conn scott/tiger

Connected.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

DEPT                           TABLE

EMP                            TABLE

BONUS                          TABLE

SALGRADE                       TABLE

SQL> create table emp_ogg as select * from emp;

SQL> alter table emp_ogg add constraint pk_emp_ogg primary key(empno);

SQL> create table dept_ogg as select * from dept;

SQL> alter table dept_ogg add constraint pk_dept_ogg primary key(deptno);

Table altered.

2)Target system

[oracle@gc5 ogg]$ !sql

sqlplus '/as sysdba'

SQL> create tablespace tbs_gguser datafile '/u01/app/oracle/oradata/torautf/gguser.dbf' size 50M autoextend on;

SQL> create user ogg identified by ogg default tablespace tbs_gguser temporary tablespace TEMP 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> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

DEPT                           TABLE

EMP                            TABLE

BONUS                          TABLE

SALGRADE                       TABLE

SQL> create table emp_ogg as select * from emp where 1=2;

SQL> create table dept_ogg as select * from dept where 1=2;

SQL> grant INSERT, UPDATE, DELETE on scott.emp_ogg to ogg;

SQL>  grant INSERT, UPDATE, DELETE on scott.dept_ogg to ogg;

SQL> alter table emp_ogg add constraint pk_emp_ogg primary key(empno);

SQL> alter table dept_ogg add constraint pk_dept_ogg primary key(deptno);

3)開啟資料庫補充日誌Source system

SQL>  alter database add supplemental log data;

SQL> alter system switch logfile;

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME

--------

YES

4)開啟歸檔模式Source system

[oracle@gc1 ~]$ mkdir arch

[oracle@gc1 ~]$!sql

SQL> alter system set log_archive_dest_1='location=/home/oracle/arch' scope=spfile;

SQL> shutdown immediate

SQL> startup mount

SQL> alter database archivelog ;

SQL> alter database open;

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/arch

Oldest online log sequence     3

Next log sequence to archive   5

Current log sequence           5

5)開啟強記日誌Source system

SQL> alter database force logging;

SQL> SELECT force_logging FROM v$database;

FOR

---

YES

6)把要同步的表開啟日誌補充,使其可以傳送

[oracle@gc1 ogg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 10.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> DBLOGIN USERID ogg, PASSWORD ogg ---登入到源資料庫

Successfully logged into database.

GGSCI (gc1) 2>  ADD TRANDATA scott.EMP_OGG 

Logging of supplemental redo data enabled for table SCOTT.EMP_OGG.

GGSCI (gc1) 3>  ADD TRANDATA scott.DEPT_OGG

Logging of supplemental redo data enabled for table SCOTT.DEPT_OGG.

GGSCI (gc1) 4>  INFO TRANDATA scott.*      ---檢視可傳送的表

Logging of supplemental redo log data is disabled for table SCOTT.BONUS.

Logging of supplemental redo log data is disabled for table SCOTT.DEPT.

Logging of supplemental redo log data is enabled for table SCOTT.DEPT_OGG

Logging of supplemental redo log data is disabled for table SCOTT.EMP.

Logging of supplemental redo log data is enabled for table SCOTT.EMP_OGG

Logging of supplemental redo log data is disabled for table SCOTT.SALGRADE.

  1. 配置管理程式MGR,若系統關閉,需要手動啟動

Source system

[oracle@gc1 ogg]$ ./ggsci

GGSCI (gc1) 5> EDIT PARAMS MGR

PORT 7809                      ---管理程式啟動後所監聽的埠號

PURGEOLDEXTRACTS ./dirdat, USECHECKPOINTS

---要跟蹤的檔案放到/u01/app/ogg/dirdat目錄下

GGSCI (gc1) 6> START MGR       ---啟動管理程式

Manager started.

GGSCI (gc1) 7> INFO MGR        ---檢視

Manager is running (IP port gc1.7809).

Target system

[oracle@gc5 ogg]$ ./ggsci

GGSCI (gc5) 1> EDIT PARAMS MGR

PORT 7809

PURGEOLDEXTRACTS /u01/app/ogg/dirdat, USECHECKPOINTS

GGSCI (gc5) 4>  START MGR

Manager started.

GGSCI (gc5) 5> INFO MGR

Manager is running (IP port gc5.7809).

6、第一次同步

第一次初始化載入步驟,只做一次就可以,目的是要讓源資料庫中的表和目標資料庫中的表初始化同步,初步變成一樣後就不需要在初始化了,再次初始化會出錯

第一次同步源資料庫和目標資料庫中要同步的表,源資料中表的結構和目標資料庫中表的結構要一樣,可以用IMP匯入表到目標資料庫

1)Source system

[oracle@gc1 ogg]$ ./ggsci

GGSCI (gc1) 1> ADD EXTRACT EINI_1, SOURCEISTABLE

EXTRACT added.

 

GGSCI (gc1) 2>  INFO EXTRACT *, TASKS

EXTRACT    EINI_1    Initialized   2014-08-12 08:51   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 EMP_OGG and DEPT_OGG

EXTRACT EINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

RMTHOST gc5, MGRPORT 7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.EMP_OGG;

TABLE scott.DEPT_OGG;

2)Target system

SPECIALRUN:表示只為初始化執行一次,執行一次以後就不執行了,停止

GGSCI (gc5) 6>  ADD REPLICAT RINI_1, SPECIALRUN

REPLICAT added.

GGSCI (gc5) 7> INFO REPLICAT *, TASKS

REPLICAT   RINI_1    Initialized   2014-08-12 08:52   Status STOPPED

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

Log Read Checkpoint  Not Available

Task                 SPECIALRUN

GGSCI (gc5) 8> 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.*;

3)啟動EXTRACT程式,測試第一次初始化同步

source system

GGSCI (gc1) 4> START EXTRACT EINI_1

Sending START request to MANAGER ...

EXTRACT EINI_1 starting

檢視日誌資訊

GGSCI (gc1) 5>  VIEW REPORT EINI_1

2014-08-12 08:53:46  GGS INFO        414  Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is used.

***********************************************************************

                 Oracle GoldenGate Capture for Oracle

                      Version 10.4.0.19 Build 002

   Linux, x86, 32bit (optimized), Oracle 10 on Sep 18 2009 00:01:59

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

                    Starting at 2014-08-12 08:53:46

***********************************************************************

Operating System Version:

Linux

Version #1 SMP Tue Aug 18 15:51:54 EDT 2009, Release 2.6.18-164.el5

Node: gc1

Machine: i686

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 2619

Description:

***********************************************************************

**            Running with the following parameters                  **

***********************************************************************

-- GoldenGate Initial Data Capture

-- for EMP_OGG and DEPT_OGG

EXTRACT EINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

Set environment variable (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ***

RMTHOST gc5, MGRPORT 7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.EMP_OGG;

Using the following key columns for source table SCOTT.EMP_OGG: EMPNO.

TABLE scott.DEPT_OGG;

Using the following key columns for source table SCOTT.DEPT_OGG: DEPTNO.

CACHEMGR virtual memory values (may have been adjusted)

CACHEBUFFERSIZE:                         64K

CACHESIZE:                                2G

CACHEBUFFERSIZE (soft max):               4M

CACHEPAGEOUTSIZE (normal):                4M

PROCESS VM AVAIL FROM OS (min):        2.91G

CACHESIZEMAX (strict force to disk):   2.67G

Database Version:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

 

Database Language and Character Set:

NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK"

NLS_LANGUAGE     = "AMERICAN"

NLS_TERRITORY    = "AMERICA"

NLS_CHARACTERSET = "ZHS16GBK"

 

Processing table SCOTT.EMP_OGG

 

Processing table SCOTT.DEPT_OGG

 

***********************************************************************

*                   ** Run Time Statistics **                         *

***********************************************************************

Report at 2014-08-12 08:53:52 (activity since 2014-08-12 08:53:46)

 

Output to RINI_1:

 

From Table SCOTT.EMP_OGG:

       #                   inserts:        14

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

From Table SCOTT.DEPT_OGG:

       #                   inserts:         4

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

Target system

GGSCI (gc5) 9>  VIEW REPORT RINI_1

***********************************************************************

                 Oracle GoldenGate Delivery for Oracle

                      Version 10.4.0.19 Build 002

   Linux, x86, 32bit (optimized), Oracle 10 on Sep 18 2009 00:08:30

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

                    Starting at 2014-08-12 08:53:47

***********************************************************************

Operating System Version:

Linux

Version #1 SMP Tue Aug 18 15:51:54 EDT 2009, Release 2.6.18-164.el5

Node: gc5

Machine: i686

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 2458

Description:

***********************************************************************

**            Running with the following parameters                  **

***********************************************************************

-- GoldenGate Initial Load Delivery

REPLICAT RINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

Set environment variable (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

ASSUMETARGETDEFS

USERID ogg, PASSWORD ***

DISCARDFILE ./dirrpt/RINIaa.dsc, PURGE

MAP scott.*, TARGET scott.*;

CACHEMGR virtual memory values (may have been adjusted)

CACHEBUFFERSIZE:                         64K

CACHESIZE:                              512M

CACHEBUFFERSIZE (soft max):               4M

CACHEPAGEOUTSIZE (normal):                4M

PROCESS VM AVAIL FROM OS (min):           1G

CACHESIZEMAX (strict force to disk):    881M

 

Database Version:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

 

Database Language and Character Set:

NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK"

NLS_LANGUAGE     = "AMERICAN"

NLS_TERRITORY    = "AMERICA"

NLS_CHARACTERSET = "ZHS16GBK"

For further information on character set settings, please refer to user manual.

***********************************************************************

**                     Run Time Messages                             **

***********************************************************************

Wildcard MAP resolved (entry SCOTT.*):

  MAP SCOTT.EMP_OGG, TARGET scott.EMP_OGG;

Using following columns in default map by name:

  EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO

Using the following key columns for target table SCOTT.EMP_OGG: EMPNO.

Wildcard MAP resolved (entry SCOTT.*):

  MAP SCOTT.DEPT_OGG, TARGET scott.DEPT_OGG;

Using following columns in default map by name:

  DEPTNO, DNAME, LOC

Using the following key columns for target table SCOTT.DEPT_OGG: DEPTNO.

***********************************************************************

*                   ** Run Time Statistics **                         *

***********************************************************************

Report at 2014-08-12 08:53:58 (activity since 2014-08-12 08:53:53)

From Table SCOTT.EMP_OGG to SCOTT.EMP_OGG:

       #                   inserts:        14

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

From Table SCOTT.DEPT_OGG to SCOTT.DEPT_OGG:

       #                   inserts:         4

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

4)檢視目標庫資料是否同步,資料已經傳過來了

SQL> conn scott/tiger

Connected.

SQL> select * from emp_ogg;

SQL> select * from dept_ogg;

7、配置capture(捕獲)引數

source system

1)配置引數EORA_1

GGSCI (gc1) 6>  EDIT PARAMS EORA_1

-- Change Capture parameter file to capture

-- EMP_OGG and DEPT_OGG changes

EXTRACT EORA_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

EXTTRAIL ./dirdat/aa --跟蹤提取的檔案放在/u01/app/ogg/dirdat下一aa開頭的檔案中

TABLE scott.EMP_OGG;     --capture要監控的表名

TABLE scott.DEPT_OGG;

2)新增程式EXTRACT,現在開始同步日誌

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

EXTRACT added.

3)新增跟蹤檔案給EORA_1用,大小為5M

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

EXTTRAIL added.

4)啟動程式,檢視狀態

GGSCI (gc1) 9> START EXTRACT EORA_1

Sending START request to MANAGER ...

EXTRACT EORA_1 starting

GGSCI (gc1) 10> INFO EXTRACT EORA_1

EXTRACT    EORA_1    Last Started 2014-08-12 09:00   Status RUNNING

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

Log Read Checkpoint  Oracle Redo Logs

                     2014-08-12 08:58:29  Seqno 6, RBA 284688

5)檢視跟蹤的日誌資訊

[oracle@gc1 ogg]$  ll /u01/app/ogg/dirdat/

total 4

-rw-rw-rw- 1 oracle oinstall 893 Aug 12 09:00 aa000000

8、在源庫配置傳遞程式

1)配置引數

[oracle@gc1 ogg]$ ./ggsci

GGSCI (gc1) 1> EDIT PARAMS PORA_1

-- Data Pump parameter file to read the local

-- trail of EMP_OGG and DEPT_OGG changes

EXTRACT PORA_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

PASSTHRU

RMTHOST gc5, MGRPORT 7809     --將捕獲的日誌傳送到gc57809

RMTTRAIL ./dirdat/pa          --傳送到/u01/app/ogg/dirdat下以pa開頭的檔案儲存

TABLE scott.EMP_OGG;          --要傳送的表

TABLE scott.DEPT_OGG;

2)告訴PORA_1,傳送/u01/app/ogg/dirdat/aa 的跟蹤資訊

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

EXTRACT added.

3)檢視

GGSCI (gc1) 3>  INFO EXTRACT PORA_1

EXTRACT    PORA_1    Initialized   2014-08-12 09:04   Status STOPPED

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

Log Read Checkpoint  File ./dirdat/aa000000

                     First Record  RBA 0

9、在源資料庫端配置遠端的路徑及檔案

1)把捕獲到的資訊傳送到遠端的/u01/app/ogg/dirdat下的pa檔案中

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

RMTTRAIL added.

2)啟動傳送,一直執行

GGSCI (gc1) 5>  START EXTRACT PORA_1

Sending START request to MANAGER ...

EXTRACT PORA_1 starting

3)檢視

GGSCI (gc1) 6> INFO EXTRACT PORA_1

EXTRACT    PORA_1    Last Started 2014-08-12 09:06   Status RUNNING

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

Log Read Checkpoint  File ./dirdat/aa000000

                     First Record  RBA 0

4)在目標庫上檢視

[oracle@gc5 ogg]$ ll /u01/app/ogg/dirdat/

total 0

-rw-rw-rw- 1 oracle oinstall 0 Aug 12 09:06 pa000000

10、Configure replicat(複製) process in target system

1)配置GLOBALS parameter

GGSCI (gc5) 1>  EDIT PARAMS ./GLOBALS

CHECKPOINTTABLE ogg.ggschkpt

2)退出,登入到目標資料庫

GGSCI (gc5) 1> exit

[oracle@gc5 ogg]$ ./ggsci

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

Successfully logged into database.

3)ogg把檢查點資訊放到這個表當中,專門存放checkpoint的表

GGSCI (gc5) 2> ADD CHECKPOINTTABLE

No checkpoint table specified, using GLOBALS specification (ogg.ggschkpt)...

Successfully created checkpoint table OGG.GGSCHKPT.

4)檢視

SQL> conn ogg/ogg

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

GGSCHKPT                       TABLE

11、配置提取程式和引數target system

1)新增提取傳送過來的資訊檔案

[oracle@gc5 ogg]$ ./ggsci

GGSCI (gc5) 1> ADD REPLICAT RORA_1, EXTTRAIL ./dirdat/pa

REPLICAT added.

2)配置引數

GGSCI (gc5) 2> EDIT PARAM RORA_1

-- Change Delivery parameter file to apply

-- EMP_OGG and DEPT_OGG Changes

REPLICAT RORA_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

HANDLECOLLISIONS

ASSUMETARGETDEFS

DISCARDFILE ./dirrpt/RORA_aa.DSC, PURGE

MAP scott.emp_ogg, TARGET scott.emp_ogg;

MAP scott.dept_ogg, TARGET scott.dept_ogg;

3)啟動程式

GGSCI (gc5) 3> START REPLICAT RORA_1

Sending START request to MANAGER ...

REPLICAT RORA_1 starting

4)檢視

GGSCI (gc5) 4> INFO REPLICAT RORA_1

REPLICAT   RORA_1    Last Started 2014-08-12 09:14   Status RUNNING

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

Log Read Checkpoint  File ./dirdat/pa000000

                     First Record  RBA 0

12、在源庫上進行DML操作,檢視目標庫表的變化

target system檢視

SQL> conn scott/tiger

Connected.

SQL> select * from emp_ogg;

 EMPNO ENAME      JOB          MGR HIREDATE         SAL       COMM     DEPTNO

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

 7900 JAMES      CLERK           7698 03-DEC-81        950               30

 7902 FORD       ANALYST         7566 03-DEC-81       3000               20

 7934 MILLER     CLERK           7782 23-JAN-82       1300               10

1)source system  INSERT INTO操作

SQL> conn scott/tiger

Connected.

SQL> INSERT INTO emp_ogg VALUES(1111,'SMITH','CLERK',7902,'12-DEC-80',800,100,20);

1 row created.

SQL> INSERT INTO emp_ogg VALUES(2222,'ALLEN',' SALESMAN',7698,'20-FEB-81',600,50,30);

1 row created.

SQL> commit;

target system檢視

SQL> select * from emp_ogg;

EMPNO ENAME      JOB         MGR HIREDATE         SAL         COMM        DEPTNO

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

 7900 JAMES      CLERK           7698 03-DEC-81        950                    30

 7902 FORD       ANALYST         7566 03-DEC-81       3000                    20

 7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

 1111 SMITH      CLERK           7902 12-DEC-80        800        100         20

 2222 ALLEN       SALESMAN       7698 20-FEB-81        600         50         30

2)source system  update操作

SQL> update emp_ogg set ename='CUUG' where empno=1111;

1 row updated.

SQL> commit;

target system檢視

SQL> select * from emp_ogg;

EMPNO ENAME      JOB           MGR HIREDATE         SAL       COMM      DEPTNO

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

 7900 JAMES      CLERK           7698 03-DEC-81        950                    30

 7902 FORD       ANALYST         7566 03-DEC-81       3000                    20

 7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

 1111 CUUG       CLERK           7902 12-DEC-80        800        100         20

 2222 ALLEN       SALESMAN       7698 20-FEB-81        600         50         30

3)source system  delete操作

SQL> delete from emp_ogg where empno=2222;

1 row deleted.

SQL> commit;

target system檢視

SQL> select * from emp_ogg;

EMPNO ENAME      JOB           MGR HIREDATE         SAL       COMM      DEPTNO

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

 7900 JAMES      CLERK           7698 03-DEC-81        950                    30

 7902 FORD       ANALYST         7566 03-DEC-81       3000                    20

 7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

 1111 CUUG       CLERK           7902 12-DEC-80        800        100         20

 


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

相關文章