一、实验环境介绍:
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用户来安装
[oracle@testing gg11]$ pwd
/u01/app/oracle/gg11
[oracle@testing 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
[oracle@testing 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
使配置生效:
[oracle@testing gg11]$ source ~/.bash_profile
3、进入 command interface:
[oracle@testing 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、创建测试表并加载初始数据
[oracle@testing ~]$ cd /u01/app/oracle/gg11/
[oracle@testing ~]$ 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
[oracle@testing 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
[oracle@testing gg11]$
将source的数据定义文件oracle.def拷贝到target端相同目录下
[root@mysqlserv dirdef]# pwd
/u01/app/oracle/gg11/dirdef
[root@mysqlserv dirdef]# ls
oracle.def
三、Target端Mysql环境准备:
1、安装ogg,本次安装不单独创建用户,就用root用户来安装
[root@mysqlserv gg11]# pwd
/u01/app/oracle/gg11
[root@mysqlserv 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
使配置生效:
[root@mysqlserv gg11]# source ~/.bash_profile
3、进入 command interface:
[root@mysqlserv 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 ggtest@'mysqlserv' identified by 'ggtest';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
四、使用OGG直接加载方式加载初始化数据
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
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
GGSCI (mysqlserv) 8> EDIT PARAMS repinit
replicat repinit
targetdb ggtest@mysqlserv: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
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
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 ggtest@mysqlserv: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=
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=
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
1、Add the Extract group (source端)
Execute the following command on the
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
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