天天看點

GoldenGate------Oracle 10g to Mysql 5.6

一、實驗環境介紹:

Oracle 作業系統:Red Hat Enterprise Linux AS release 4 (Nahant Update 8) (x86_64)

Oracle 資料庫版本:Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

OGG for Oracle版本:ogg112101_fbo_ggs_Linux_x64_ora10g_64bit

Mysql 作業系統:CentOS release 6.3 (Final) (x86_64)

Mysql 資料庫版本:mysql  5.6.14, for Linux (x86_64)

OGG for Mysql版本:Oracle GoldenGate V12.1.2.0.0 for MySQL on Linux x86-64 (131 MB)

二、Source端Oracle環境準備:

1、安裝ogg,本次安裝不單獨建立使用者,就用oracle使用者來安裝

[[email protected] gg11]$ pwd

/u01/app/oracle/gg11

[[email protected] gg11]$ ll

total 309576

-rw-rw-r--  1 oracle oinstall 227522560 Apr 23  2012 fbo_ggs_Linux_x64_ora10g_64bit.tar

-rw-r--r--  1 oracle oinstall  88807353 Jul 18 15:07 ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip

-rwxrwxrwx  1 oracle oinstall    220546 May  2  2012 OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf

-rwxrwxrwx  1 oracle oinstall     93696 May  2  2012 Oracle GoldenGate 11.2.1.0.1 README.doc

-rwxrwxrwx  1 oracle oinstall     24390 May  2  2012 Oracle GoldenGate 11.2.1.0.1 README.txt

[[email protected] gg11]$ tar xvf fbo_ggs_Linux_x64_ora10g_64bit.tar

2、編輯環境變量

vi ~/.bash_profile  添加如下兩行

export LD_LIBRARY_PATH=/u01/app/oracle/gg11:$LD_LIBRARY_PATH

export PATH=/u01/app/oracle/gg11:$PATH

使配置生效:

[[email protected] gg11]$ source ~/.bash_profile

3、進入 command interface:

[[email protected] gg11]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

Linux, x64, 64bit (optimized), Oracle 10g on Apr 23 2012 07:30:46

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

 建立基本目錄:

GGSCI (testing) 1> CREATE SUBDIRS

Creating subdirectories under current directory /u01/app/oracle/gg11

Parameter files                       /u01/app/oracle/gg11/dirprm: already exists

Report files                              /u01/app/oracle/gg11/dirrpt: created

Checkpoint files                      /u01/app/oracle/gg11/dirchk: created

Process status files               /u01/app/oracle/gg11/dirpcs: created

SQL script files                        /u01/app/oracle/gg11/dirsql: created

Database definitions files     /u01/app/oracle/gg11/dirdef: created

Extract data files                      /u01/app/oracle/gg11/dirdat: created

Temporary files                       /u01/app/oracle/gg11/dirtmp: created

Stdout files                               /u01/app/oracle/gg11/dirout: created

GGSCI (testing) 2>

建立參數檔案:

GGSCI (testing) 3> edit params mgr

寫入以下内容儲存退出

port 7809

dynamicportlist 7810-7820,7830

autostart er r*

autorestart er r*,retries 4,waitminutes 4

startupvalidationdelay 5

purgeoldextracts /home/ogg/dirdat/rt*,usecheckpoints,minkeephours 2

啟動mgr

GGSCI (testing) 5> start mgr

Manager started.

驗證mgr是否已經啟動

GGSCI (testing) 6> info mgr

Manager is running (IP port testing.7809).

4、開啟force_logging&輔助日志

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL>  select force_logging from v$database;

FOR

---

YES

SQL> alter database add supplemental log data;

Database altered.

5、建立測試表并加載初始資料

[[email protected] ~]$ cd /u01/app/oracle/gg11/

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Fri Jul 18 15:38:32 2014

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create user ggtest identified by ggtest;

User created.

SQL> grant connect,resource to ggtest;

Grant succeeded.

SQL> conn ggtest/ggtest

Connected.

SQL> @demo_ora_create

DROP TABLE tcustmer

           *

ERROR at line 1:

ORA-00942: table or view does not exist

Table created.

DROP TABLE tcustord

           *

ERROR at line 1:

ORA-00942: table or view does not exist

Table created.

SQL> @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_PRICE PRODUCT_AMOUNT TRANSACTION_ID

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

WILL 30-SEP-94    CAR             144         17520              3            100

JANE 11-NOV-95    PLANE           256        133300              1            100

 6、Add supplemental logging

GGSCI (testing) 7> DBLOGIN USERID system, PASSWORD xxxxxx

Successfully logged into database.

GGSCI (testing) 8> ADD TRANDATA ggtest.TCUSTMER

Logging of supplemental redo data enabled for table GGTEST.TCUSTMER.

GGSCI (testing) 9> ADD TRANDATA ggtest.TCUSTORD

Logging of supplemental redo data enabled for table GGTEST.TCUSTORD.

GGSCI (testing) 11> INFO TRANDATA ggtest.*

Logging of supplemental redo log data is enabled for table GGTEST.TCUSTMER.

Columns supplementally logged for table GGTEST.TCUSTMER: CUST_CODE.

Logging of supplemental redo log data is enabled for table GGTEST.TCUSTORD.

Columns supplementally logged for table GGTEST.TCUSTORD: CUST_CODE, ORDER_DATE, PRODUCT_CODE, ORDER_ID.

7、建立source端Oracle資料庫需要複制同步的資料定義檔案

GGSCI (testing) 6> edit params defgen

userid system password xxxxxx 

defsfile /u01/app/oracle/gg11/dirdef/oracle.def

table ggtest.*;

在OGG安裝目錄下執行以下指令生成資料定義檔案oracle.def

[[email protected] gg11]$ ./defgen paramfile dirprm/defgen.prm

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

        Oracle GoldenGate Table Definition Generator for Oracle

      Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230

   Linux, x64, 64bit (optimized), Oracle 10g on Apr 23 2012 05:09:39

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

                    Starting at 2014-07-18 17:17:24

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

Operating System Version:

Linux

Version #1 SMP Mon Apr 20 10:33:05 EDT 2009, Release 2.6.9-89.ELsmp

Node: testing

Machine: x86_64

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 21823

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

**            Running with the following parameters                  **

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

userid system password ******

defsfile /u01/app/oracle/gg11/dirdef/oracle.def

table ggtest.*;

Expanding wildcard ggtest.*:

Retrieving definition for GGTEST.TCUSTMER

Retrieving definition for GGTEST.TCUSTORD

Definitions generated for 2 tables in /u01/app/oracle/gg11/dirdef/oracle.def

[[email protected] gg11]$

将source的資料定義檔案oracle.def拷貝到target端相同目錄下

[[email protected] dirdef]# pwd

/u01/app/oracle/gg11/dirdef

[[email protected] dirdef]# ls

oracle.def

三、Target端Mysql環境準備:

1、安裝ogg,本次安裝不單獨建立使用者,就用root使用者來安裝

[[email protected] gg11]# pwd

/u01/app/oracle/gg11

[[email protected] gg11]# tar xvf ggs_Linux_x64_MySQL_64bit.tar

2、編輯環境變量

vi ~/.bash_profile  添加如下兩行

export LD_LIBRARY_PATH=/u01/app/oracle/gg11:$LD_LIBRARY_PATH

export PATH=/u01/app/oracle/gg11:$PATH

使配置生效:

[[email protected] gg11]# source ~/.bash_profile

3、進入 command interface:

[[email protected] gg11]# ggsci

Oracle GoldenGate Command Interpreter for MySQL

Version 12.1.2.0.0 17185003 OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316

Linux, x64, 64bit (optimized), MySQL Enterprise on Sep 24 2013 15:32:47

Operating system character set identified as UTF-8.

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

 建立基本目錄:

GGSCI (mysqlserv) 1> CREATE SUBDIRS

Creating subdirectories under current directory /u01/app/oracle/gg11

Parameter files                /u01/app/oracle/gg11/dirprm: already exists

Report files                   /u01/app/oracle/gg11/dirrpt: created

Checkpoint files               /u01/app/oracle/gg11/dirchk: created

Process status files           /u01/app/oracle/gg11/dirpcs: created

SQL script files               /u01/app/oracle/gg11/dirsql: created

Database definitions files     /u01/app/oracle/gg11/dirdef: created

Extract data files             /u01/app/oracle/gg11/dirdat: created

Temporary files                /u01/app/oracle/gg11/dirtmp: created

Credential store files         /u01/app/oracle/gg11/dircrd: created

Masterkey wallet files         /u01/app/oracle/gg11/dirwlt: created

Dump files                     /u01/app/oracle/gg11/dirdmp: created

建立參數檔案:

GGSCI (mysqlserv) 2> edit params mgr

寫入以下内容儲存退出

port 7809

啟動mgr

GGSCI (mysqlserv) 3> start mgr

Manager started.

驗證mgr是否已經啟動

GGSCI (mysqlserv) 4> info mgr

Manager is running (IP port mysqlserv.7809, Process ID 25307).

GGSCI (mysqlserv) 5>

4、建立target段mysql測試表

mysql> create database ggtest;

Query OK, 1 row affected (0.00 sec)

mysql> use ggtest;

Database changed

mysql> CREATE TABLE TCUSTMER

    -> (

    ->     CUST_CODE    VARCHAR(4)    NOT NULL,

    ->     NAME         VARCHAR(30),

    ->     CITY         VARCHAR(20),

    ->     STATE        CHAR(2),

    ->     PRIMARY KEY (CUST_CODE)

    -> );

Query OK, 0 rows affected (0.26 sec)

mysql> CREATE TABLE TCUSTORD

    -> (

    ->     CUST_CODE         VARCHAR(4)    NOT NULL,

    ->     ORDER_DATE        DATETIME      NOT NULL,

    ->     PRODUCT_CODE      VARCHAR(8)    NOT NULL,

    ->     ORDER_ID          INTEGER       NOT NULL,

    ->     PRODUCT_PRICE     DECIMAL(8,2),

    ->     PRODUCT_AMOUNT    INTEGER,

    ->     TRANSACTION_ID    FLOAT,

    ->     PRIMARY KEY (CUST_CODE, ORDER_DATE, PRODUCT_CODE, ORDER_ID)

    -> );

Query OK, 0 rows affected (0.28 sec)

mysql> show tables;

+------------------+

| Tables_in_ggtest |

+------------------+

| tcustmer         |

| tcustord         |

+------------------+

2 rows in set (0.00 sec)

mysql>

5、建立用與OGG登陸的資料庫賬戶并賦予權限

mysql> grant all on *.* to [email protected]'mysqlserv' identified by 'ggtest';

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 四、使用OGG直接加載方式加載初始化資料

GoldenGate------Oracle 10g to Mysql 5.6

Initial data capture

1. Add the initial load capture batch task group

GGSCI (testing) 1> add extract initdata,sourceistable

EXTRACT added.

GGSCI (testing) 2> info extract *, task

EXTRACT    INITDATA       Initialized   2014-07-18 16:42   Status STOPPED

Checkpoint Lag                  Not Available

Log Read Checkpoint       Not Available

                                              First Record         Record 0

Task                                     SOURCEISTABLE

2. Configure the initial load capture parameter file

GGSCI (testing) 3> edit params initdata

EXTRACT initdata

USERID system, PASSWORD xxxxxx

RMTHOST 192.168.5.100, MGRPORT 7809

RMTTASK REPLICAT, GROUP repinit

TABLE ggtest.TCUSTMER;

TABLE ggtest.TCUSTORD;

3、Add the initial load delivery batch task

Execute the following commands on the <target>  system.

GGSCI (mysqlserv) 6> ADD REPLICAT repinit,SPECIALRUN

REPLICAT added.

Verify the results:

GGSCI (mysqlserv) 7>  INFO REPLICAT *, TASKS

REPLICAT   REPINIT        Initialized   2014-07-18 16:52   Status STOPPED

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

Log Read Checkpoint      Not Available

Task                                    SPECIALRUN

GGSCI (mysqlserv) 8>

4. Configure the initial load delivery parameter file

Execute the following commands on the <target>  system.

GGSCI (mysqlserv) 8> EDIT PARAMS repinit

replicat repinit

targetdb [email protected]:3306 userid ggtest password ggtest

sourcedefs /u01/app/oracle/gg11/dirdef/oracle.def

discardfile /u01/app/oracle/gg11/dirrpt/repinit.dsc,purge

map ggtest.*,target ggtest.*;

5、Execute the initial load process

GGSCI (testing) 7> START EXTRACT initdata

Sending START request to MANAGER ...

EXTRACT INITDATA starting

Verify the results on the <source> system:

GGSCI (testing) 8> VIEW REPORT initdata

2014-07-18 17:21:51  INFO    OGG-01017  Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is used.

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

                 Oracle GoldenGate Capture for Oracle

    Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

   Linux, x64, 64bit (optimized), Oracle 10g on Apr 23 2012 07:44:10

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

                    Starting at 2014-07-18 17:21:50

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

Operating System Version:

Linux

Version #1 SMP Mon Apr 20 10:33:05 EDT 2009, Release 2.6.9-89.ELsmp

Node: testing

Machine: x86_64

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 22911

Description:

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

**            Running with the following parameters                  **

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

2014-07-18 17:21:51  INFO    OGG-03035  Operating system character set identified as UTF-8. Locale: en_US, LC_ALL:.

EXTRACT initdata

USERID system, PASSWORD ******

RMTHOST 192.168.5.100, MGRPORT 7809

RMTTASK REPLICAT, GROUP repinit

TABLE ggtest.TCUSTMER;

Using the following key columns for source table GGTEST.TCUSTMER: CUST_CODE.

TABLE ggtest.TCUSTORD;

Using the following key columns for source table GGTEST.TCUSTORD: CUST_CODE, ORDER_DATE, PRODUCT_CODE, ORDER_ID.

2014-07-18 17:21:53  INFO    OGG-01815  Virtual Memory Facilities for: COM

    anon alloc: mmap(MAP_ANON)  anon free: munmap

    file alloc: mmap(MAP_SHARED)  file free: munmap

    target directories:

    /u01/app/oracle/gg11/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)

CACHESIZE:                               64G

CACHEPAGEOUTSIZE (normal):                8M

PROCESS VM AVAIL FROM OS (min):         128G

CACHESIZEMAX (strict force to disk):     96G

Database Version:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

PL/SQL Release 10.2.0.4.0 - Production

CORE    10.2.0.4.0      Production

TNS for Linux: Version 10.2.0.4.0 - Production

NLSRTL Version 10.2.0.4.0 - Production

Database Language and Character Set:

NLS_LANG         = "AMERICAN_AMERICA.ZHS16GBK"

NLS_LANGUAGE     = "AMERICAN"

NLS_TERRITORY    = "AMERICA"

NLS_CHARACTERSET = "ZHS16GBK"

Processing table GGTEST.TCUSTMER

Processing table GGTEST.TCUSTORD

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

*                   ** Run Time Statistics **                         *

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

Report at 2014-07-18 17:21:58 (activity since 2014-07-18 17:21:52)

Output to repinit:

From Table GGTEST.TCUSTMER:

       #                   inserts:         2

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

From Table GGTEST.TCUSTORD:

       #                   inserts:         2

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

REDO Log Statistics

  Bytes parsed                    0

  Bytes output                  578

GGSCI (testing) 9>

Verify the results on the <target>  system:

GGSCI (mysqlserv) 10> VIEW REPORT repinit

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

                 Oracle GoldenGate Delivery for MySQL

 Version 12.1.2.0.0 17185003 OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316

 Linux, x64, 64bit (optimized), MySQL Enterprise on Sep 24 2013 16:30:39

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

                    Starting at 2014-07-18 17:20:18

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

Operating System Version:

Linux

Version #1 SMP Fri Jun 22 12:19:21 UTC 2012, Release 2.6.32-279.el6.x86_64

Node: mysqlserv

Machine: x86_64

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 902

Description:

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

**            Running with the following parameters                  **

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

2014-07-18 17:20:23  INFO    OGG-03059  Operating system character set identified as UTF-8.

2014-07-18 17:20:23  INFO    OGG-02695  ANSI SQL parameter syntax is used for parameter parsing.

replicat repinit

targetdb [email protected]:3306 userid ggtest password ******

sourcedefs /u01/app/oracle/gg11/dirdef/oracle.def

2014-07-18 17:20:23  INFO    OGG-03528  The source database character set, as determined from the table definition file, is windows-

936.

discardfile /u01/app/oracle/gg11/dirrpt/repinit.dsc,purge

map ggtest.*,target ggtest.*;

2014-07-18 17:20:23  INFO    OGG-01815  Virtual Memory Facilities for: COM

    anon alloc: mmap(MAP_ANON)  anon free: munmap

    file alloc: mmap(MAP_SHARED)  file free: munmap

    target directories:

    /u01/app/oracle/gg11/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)

CACHESIZE:                                2G

CACHEPAGEOUTSIZE (default):               8M

PROCESS VM AVAIL FROM OS (min):           4G

CACHESIZEMAX (strict force to disk):   3.41G

Database Version:

MySQL

Server Version: 5.6.15-ndb-7.3.4-cluster-gpl

Client Version: 5.6.10

Host Connection: mysqlserv via TCP/IP

Protocol Version: 10

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

**                     Run Time Messages                             **

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

Wildcard MAP resolved (entry ggtest.*):

  map "GGTEST"."TCUSTMER",target "ggtest"."TCUSTMER";

Using following columns in default map by name:

  CUST_CODE, NAME, CITY, STATE

Using the following key columns for target table ggtest.TCUSTMER: CUST_CODE.

2014-07-18 17:20:23  INFO    OGG-03010  Performing implicit conversion of column data from character set zhs16gbk to ISO-8859-1.

Wildcard MAP resolved (entry ggtest.*):

  map "GGTEST"."TCUSTORD",target "ggtest"."TCUSTORD";

Using following columns in default map by name:

  CUST_CODE, ORDER_DATE, PRODUCT_CODE, ORDER_ID, PRODUCT_PRICE,

  PRODUCT_AMOUNT, TRANSACTION_ID

Using the following key columns for target table ggtest.TCUSTORD: CUST_CODE, ORDER_DATE, PRODUCT_CODE, ORDER_ID.

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

*                   ** Run Time Statistics **                         *

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

Report at 2014-07-18 17:20:29 (activity since 2014-07-18 17:20:23)

From Table GGTEST.TCUSTMER to ggtest.TCUSTMER:

       #                   inserts:         2

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

From Table GGTEST.TCUSTORD to ggtest.TCUSTORD:

       #                   inserts:         2

       #                   updates:         0

       #                   deletes:         0

       #                  discards:         0

CACHE OBJECT MANAGER statistics

CACHE MANAGER VM USAGE

vm current     =      0    vm anon queues =      0

vm anon in use =      0    vm file        =      0

vm used max    =      0    ==> CACHE BALANCED

CACHE CONFIGURATION

cache size            =   2G   cache force paging = 3.41G

buffer min            =  64K   buffer max (soft)  =   8M

pageout eligible size =   8M

================================================================================

RUNTIME STATS FOR SUPERPOOL

CACHE Transaction Stats

trans active    =      0    max concurrent =      0

non-zero total  =      0    trans total    =      0

CACHE File Caching

filecache rqsts        =      0    bytes to disk      =      0

file retrieves         =      0    objs filecached    =      0

queue entries          =      0    queue processed    =      0

queue entry not needed =      0    queue not signaled =      0

fc requesting obj      =      0

CACHE MANAGEMENT

buffer links   =      0   anon gets   =      0

forced unmaps  =      0   cnnbl try   =      0

cached out     =      0

Allocation Request Distribution

< 128B:       0

 128B:        0         0     | 512B:        0         0

   2K:        0         0     |   8K:        0         0

  32K:        0         0     | 128K:        0         0

 512K:        0         0     |   2M:        0         0

   8M:        0         0     |  32M:        0         0

 128M:        0         0

Cached Transaction Size Distribution

    0:        0

 < 4K:        0

   4K:        0         0     |  16K:        0         0

  64K:        0         0     | 256K:        0         0

   1M:        0         0     |   4M:        0         0

  16M:        0         0     |  64M:        0         0

 256M:        0         0     |   1G:        0         0

   4G:        0         0     |  16G:        0         0

  64G:        0         0     | 256G:        0         0

   1T:        0         0     |   4T:        0         0

  16T:        0         0     |  64T:        0         0

 256T:        0         0     |1024T:        0         0

================================================================================

CUMULATIVE STATS FOR SUPERPOOL (PREVIOUS RUNS ONLY)

CACHE Transaction Stats

trans active    =      0    max concurrent =      0

non-zero total  =      0    trans total    =      0

CACHE File Caching

filecache rqsts        =      0    bytes to disk      =      0

file retrieves         =      0    objs filecached    =      0

queue entries          =      0    queue processed    =      0

queue entry not needed =      0    queue not signaled =      0

fc requesting obj      =      0

CACHE MANAGEMENT

buffer links   =      0   anon gets   =      0

forced unmaps  =      0   cnnbl try   =      0

cached out     =      0

Allocation Request Distribution

< 128B:       0

 128B:        0         0     | 512B:        0         0

   2K:        0         0     |   8K:        0         0

  32K:        0         0     | 128K:        0         0

 512K:        0         0     |   2M:        0         0

   8M:        0         0     |  32M:        0         0

 128M:        0         0

Cached Transaction Size Distribution

    0:        0

 < 4K:        0

   4K:        0         0     |  16K:        0         0

  64K:        0         0     | 256K:        0         0

   1M:        0         0     |   4M:        0         0

  16M:        0         0     |  64M:        0         0

 256M:        0         0     |   1G:        0         0

   4G:        0         0     |  16G:        0         0

  64G:        0         0     | 256G:        0         0

   1T:        0         0     |   4T:        0         0

  16T:        0         0     |  64T:        0         0

 256T:        0         0     |1024T:        0         0

QUEUE Statistics

num queues =     10     q hits =      0      q misses =      0

queue size  q hits  curlen  maxlen     cannibalized

  0   64K      0       0       0       0

  1  128K      0       0       0       0

  2  256K      0       0       0       0

  3  512K      0       0       0       0

  4    1M      0       0       0       0

  5    2M      0       0       0       0

  6    4M      0       0       0       0

  7    8M      0       0       0       0

  8   16M      0       0       0       0

  9   32M      0       0       0       0

================================================================================

RUNTIME STATS FOR CACHE POOL #0

POOL INFO   group: repinit  id: p902_BLOB

trans active  =       0   trans concurrent (max) =     0

trans total   =       0   (0 )

flag          = 0x00000030

last error    = (0=<none>)

Allocation Request Distribution

< 128B:       0

 128B:        0         0     | 512B:        0         0

   2K:        0         0     |   8K:        0         0

  32K:        0         0     | 128K:        0         0

 512K:        0         0     |   2M:        0         0

   8M:        0         0     |  32M:        0         0

 128M:        0         0

================================================================================

CUMULATIVE STATS FOR CACHE POOL #0 (PREVIOUS RUNS ONLY)

POOL INFO   group: repinit  id: p902_BLOB

trans active  =       0   trans concurrent (max) =     0

trans total   =       0   (0 )

flag          = 0x00000030

last error    = (0=<none>)

Allocation Request Distribution

< 128B:       0

 128B:        0         0     | 512B:        0         0

   2K:        0         0     |   8K:        0         0

  32K:        0         0     | 128K:        0         0

 512K:        0         0     |   2M:        0         0

   8M:        0         0     |  32M:        0         0

 128M:        0         0

GGSCI (mysqlserv) 11>

檢視mysql資料庫上是否已經初始化資料成功:

mysql> select * from tcustmer;

+-----------+------------------+---------+-------+

| CUST_CODE | NAME             | CITY    | STATE |

+-----------+------------------+---------+-------+

| JANE      | ROCKY FLYER INC. | DENVER  | CO    |

| WILL      | BG SOFTWARE CO.  | SEATTLE | WA    |

+-----------+------------------+---------+-------+

2 rows in set (0.00 sec)

mysql> select * from tcustord

    -> ;

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

| CUST_CODE | ORDER_DATE          | PRODUCT_CODE | ORDER_ID | PRODUCT_PRICE | PRODUCT_AMOUNT | TRANSACTION_ID |

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

| JANE      | 1995-11-11 13:52:00 | PLANE        |      256 |     133300.00 |              1 |            100 |

| WILL      | 1994-09-30 15:33:00 | CAR          |      144 |      17520.00 |              3 |            100 |

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

2 rows in set (0.00 sec)

資料初始化完成!

五、Configure Change Capture

GoldenGate------Oracle 10g to Mysql 5.6

1、Add the Extract group (source端)

Execute the following command on the  <source> system to add an Extract group named EORA<unique id>.

GGSCI (testing) 1> ADD EXTRACT EORA1, TRANLOG, BEGIN NOW, THREADS 1

EXTRACT added.

Verify the results:

GGSCI (testing) 2> INFO EXTRACT EORA1

EXTRACT    EORA1           Initialized   2014-07-20 10:50   Status STOPPED

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

Log Read Checkpoint         Oracle Redo Logs

                                            2014-07-20 10:50:34  Thread 1, Seqno 0, RBA 0

                                            SCN 0.0 (0)

2、Create the Extract parameter file

Execute the following commands on the <source> system.

GGSCI (testing) 3> edit params EORA1

寫入以下内容儲存退出:

extract EORA1

userid system password xxxxxx

exttrail /u01/app/oracle/gg11/dirdat/or

table ggtest.*;

3、定義本地trail與Extract的連結關系:

GGSCI (testing) 17> add exttrail /u01/app/oracle/gg11/dirdat/or,extract eora1

EXTTRAIL added.

4、add the data pump程序

GGSCI (testing) 6> add extract pump1,exttrailsource /u01/app/oracle/gg11/dirdat/or,,begin now

EXTRACT added.

定義remote trail與data pump的連結關系

GGSCI (testing) 7> add rmttrail /u01/app/oracle/gg11/dirdat/rt,extract pump1

RMTTRAIL added.

5、 建立data pump參數檔案

GGSCI (testing) 8> edit params pump1

将以下内容插入後儲存退出:

extract pump1

userid system, password xxxxxx

rmthost 192.168.5.100, mgrport 7809

rmttrail /u01/app/oracle/gg11/dirdat/rt

passthru

table ggtest.*;

6、啟動捕獲程序和data pump程序

GGSCI (testing) 18> start EORA1

Sending START request to MANAGER ...

EXTRACT EORA1 starting

确認extract EORA1已啟動

GGSCI (testing) 19> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                          

EXTRACT     RUNNING     EORA1       00:00:00      00:00:00   

EXTRACT     STOPPED     PUMP1       00:00:00      00:18:10   

啟動data pump程序

GGSCI (testing) 20> start pump1

Sending START request to MANAGER ...

EXTRACT PUMP1 starting

确認data pump程序已啟動

GGSCI (testing) 21>  info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                          

EXTRACT     RUNNING     EORA1       00:00:00      00:00:00   

EXTRACT     RUNNING     PUMP1       00:00:00      00:00:08   

六、配置Change Delivery

1. 在target系統上建立checkpoint table

GGSCI (mysqlserv) 1> dblogin sourcedb [email protected]:3306 userid ggtest password ggtest

Successfully logged into database.

GGSCI (mysqlserv) 3> add checkpointtable ggtest.checkpoint_table

Successfully created checkpoint table ggtest.checkpoint_table.

與Oracle資料庫登陸資料庫不同的地方在于需要加上sourcedb這個參數指定登陸的資料庫。

檢視checkpoint table是否生成

mysql> use ggtest

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+----------------------+

| Tables_in_ggtest     |

+----------------------+

| checkpoint_table     |

| checkpoint_table_lox |

| tcustmer             |

| tcustord             |

+----------------------+

4 rows in set (0.00 sec)

2、添加一個Replicat組用于線上同步複制應用

GGSCI (mysqlserv) 6> add replicat rep1,exttrail /u01/app/oracle/gg11/dirdat/rt,checkpointtable ggtest.checkpoint_table

REPLICAT added.

3、建立一個Replicat參數檔案

GGSCI (mysqlserv) 7> edit params rep1

插入以下内容後儲存退出:

replicat rep1

targetdb [email protected]:3306 userid ggtest password ggtest

handlecollisions

sourcedefs /u01/app/oracle/gg11/dirdef/oracle.def

discardfile /u01/app/oracle/gg11/dirrpt/rep1.dsc,purge

map ggtest.*,target ggtest.*;

由于是異構環境,是以要指定sourcedefs參數,使用source資料庫的資料定義檔案。

4、 在target端啟動改變同步線上複制程序

GGSCI (mysqlserv) 8>  start rep1

Sending START request to MANAGER ...

REPLICAT REP1 starting

GGSCI (mysqlserv) 9> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                          

REPLICAT    RUNNING     REP1        00:00:00      00:00:05   

GGSCI (mysqlserv) 10> view report rep1

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

                 Oracle GoldenGate Delivery for MySQL

 Version 12.1.2.0.0 17185003 OGGCORE_12.1.2.0.0_PLATFORMS_130924.1316

 Linux, x64, 64bit (optimized), MySQL Enterprise on Sep 24 2013 16:30:39

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

                    Starting at 2014-07-20 11:48:59

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

Operating System Version:

Linux

Version #1 SMP Fri Jun 22 12:19:21 UTC 2012, Release 2.6.32-279.el6.x86_64

Node: mysqlserv

Machine: x86_64

                         soft limit   hard limit

Address Space Size   :    unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

Process id: 4950

Description:

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

**            Running with the following parameters                  **

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

2014-07-20 11:48:59  INFO    OGG-03059  Operating system character set identified as UTF-8.

2014-07-20 11:48:59  INFO    OGG-02695  ANSI SQL parameter syntax is used for parameter parsing.

replicat rep1

targetdb [email protected]:3306 userid ggtest password ******

handlecollisions

sourcedefs /u01/app/oracle/gg11/dirdef/oracle.def

2014-07-20 11:48:59  INFO    OGG-03528  The source database character set, as determined from the table definition file, is windows-

936.

discardfile /u01/app/oracle/gg11/dirrpt/rep1.dsc,purge

map ggtest.*,target ggtest.*;

2014-07-20 11:48:59  INFO    OGG-01815  Virtual Memory Facilities for: COM

    anon alloc: mmap(MAP_ANON)  anon free: munmap

    file alloc: mmap(MAP_SHARED)  file free: munmap

    target directories:

    /u01/app/oracle/gg11/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)

CACHESIZE:                                2G

CACHEPAGEOUTSIZE (default):               8M

PROCESS VM AVAIL FROM OS (min):           4G

CACHESIZEMAX (strict force to disk):   3.41G

Database Version:

MySQL

Server Version: 5.6.15-ndb-7.3.4-cluster-gpl

Client Version: 5.6.10

Host Connection: 192.168.5.100 via TCP/IP

Protocol Version: 10

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

**                     Run Time Messages                             **

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

Opened trail file /u01/app/oracle/gg11/dirdat/rt000000 at 2014-07-20 11:48:59

七、測試線上同步

source端:

INSERT INTO TCUSTMER

VALUES

(

    'LP',

    'BG SOFTWARE CO.',

    'BJ',

    'WA'

);

commit;

SQL> select * from TCUSTMER;

CUST NAME                           CITY                 ST

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

LP   BG SOFTWARE CO.                BJ                   WA

WILL BG SOFTWARE CO.                SEATTLE              WA

JANE ROCKY FLYER INC.               DENVER               CO

target端:

mysql> select * from tcustmer;

+-----------+------------------+---------+-------+

| CUST_CODE | NAME             | CITY    | STATE |

+-----------+------------------+---------+-------+

| JANE      | ROCKY FLYER INC. | DENVER  | CO    |

| LP        | BG SOFTWARE CO.  | BJ      | WA    |

| WILL      | BG SOFTWARE CO.  | SEATTLE | WA    |

+-----------+------------------+---------+-------+

3 rows in set (0.00 sec)

source端:

SQL> delete from TCUSTORD t where t.CUST_CODE='JANE';

1 row deleted.

SQL> commit;

SQL> select * from TCUSTORD;

CUST ORDER_DATE   PRODUCT_   ORDER_ID PRODUCT_PRICE PRODUCT_AMOUNT TRANSACTION_ID

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

WILL 30-SEP-94    CAR             144         17520              3            100

target端:

mysql> select * from TCUSTORD;

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

| CUST_CODE | ORDER_DATE          | PRODUCT_CODE | ORDER_ID | PRODUCT_PRICE | PRODUCT_AMOUNT | TRANSACTION_ID |

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

| WILL      | 1994-09-30 15:33:00 | CAR          |      144 |      17520.00 |              3 |            100 |

+-----------+---------------------+--------------+----------+---------------+----------------+----------------+

1 row in set (0.00 sec)

至此Oracle to Mysql異構資料庫之間初始化加載資料、change synchronization單向複制配置完成。

參考文章:http://www.douban.com/note/320487390/

gg_lab_student_guide.pdf



繼續閱讀