您的位置:首页 > 数据库 > Oracle

mysql-oracle无pump进程的ogg

2016-07-06 18:58 274 查看
GoldenGate for Mysql to Oracle

一、基础准备

1、安装OGG软件
用户组必须与mysql的用户组相同
Oracle GoldenGate 11g for MySQL installed in the source <install location>.
Note: Make sure you install Oracle GoldenGate for MySQL with an OS account that is in the same OS group as the MySQL Server OS account

2、配置环境变量
可以使用临时变量
Shell>export MYSQL_HOME=<MySQL bin location>
Shell>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<installation location of Oracle GoldenGate for MySQL>

也可手工配置

[root@eastmoney ~]# vi /etc/profile

OGG_HOME=/opt/app/OGG_MYSQL
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/app/OGG_MYSQL
PATH=$PATH:/opt/app/OGG_MYSQL

3、更改数据库参数(备库)

vi /etc/my.cnf
datadir=/var/lib/mysql
log-bin=/var/lib/mysql/mysql-bin
log_bin_index=/var/lib/mysql/mysql-bin.index
max_binlog_size=4096
binlog_format=ROW
socket=/tmp/mysql.sock
explicit_defaults_for_timestamp=true
server-id=1
log-slave-updates (备库启用)
[client]
socket=/tmp/mysql.sock

需要添加explicit_defaults_for_timestamp和server-id,否则启动保错:
root@n1:/var# service mysqld start
Initializing MySQL database: 2016-04-07T07:28:38.199235Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-07T07:28:38.202302Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
2016-04-07T07:28:38.202325Z 0 [ERROR] Aborting

更改mysql登陆密码
http://www.07net01.com/storage_networking/2016/01/1141976.html
update mysql.user set authentication_string=password('root') where user='root';
进入mysql,执行查询报错:
mysql> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

root@n1:~# mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
密码设置要包含大小写字母、数字、字符:Password@1
然后登陆:mysql -u root -p 就可以了

4、检查ODBC是否安装
Verify that the MySQL ODBC connector is installed. As the root Linux user run the following command:
Shell>rpm -qa *odbc*
mysql-connector-odbc-3.51.26r1127-1.el5

如果没有安装,可以采用如下步骤:
If it doesn't already exist, create the /usr/local/etc/odbc.ini file. Add the following into the file:
[ODBC Data Sources]
<source db> = MyODBC 3.51 Driver DSN
[<source db>]
Driver = /usr/lib/libmyodbc3.so
Description = Connector/ODBC 3.51 Driver DSN
Server = localhost
Port = 3306
User = <source db login>
Password = <source db password>
Database = <source db name>
Option = 3
Socket = /tmp/mysql.sock

export ODBCINI=/usr/local/etc/odbc.ini
export ODBCSYSINI=/usr/local/etc

mysql> create user ogg@'%' identified by 'Password@1';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to 'ogg'@'%' identified by 'Password@1';
Query OK, 0 rows affected, 1 warning (0.00 sec)

5、安装OGG
静默安装OGG 12c for oracle:
[oracle@n2 response]$ vi oggcore.rsp
[oracle@n2 response]$
[oracle@n2 response]$ cat oggcore.rsp |grep -v "#" |grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_ogginstall_response_schema_v12_1_2
INSTALL_OPTION=ORA11g
SOFTWARE_LOCATION=/opt/app/OGG_MYSQL
START_MANAGER=TRUE
MANAGER_PORT=3311
DATABASE_LOCATION=/opt/app/oracle/product/11.2.0/dbhome_1
INVENTORY_LOCATION=/opt/app/oraInventory
UNIX_GROUP_NAME=oinstall

./runInstaller -silent -ignoreSysPrereqs -responseFile /opt/app/OGG_MYSQL/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp

6、检查mysql字符集

MySQL字符集多种多样,下面为您列举了其中三种最常见的MySQL字符集查看方法,该方法供您参考,希望对您学习MySQL数据库能有所启迪。

一、查看MySQL数据库服务器和数据库MySQL字符集。
mysql> show variables like '%char%';

二、查看MySQL数据表(table)的MySQL字符集。
mysql> show table status from sqlstudy_db like '%countries%';

三、查看MySQL数据列(column)的MySQL字符集。
mysql> show full columns from countries;

7、mysql测试数据装载(测试使用)
use mydb1
mysql> create table t_t1 (name, varchar(10));
mysql> create table test (jj int,kk varchar(20));
Query OK, 0 rows affected (0.05 sec)

mysql> create table oo (id int,ll date);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into test values(1,'erwe');
Query OK, 1 row affected (0.03 sec)

mysql> insert into test values(1,'erwe');
Query OK, 1 row affected (0.04 sec)

mysql> insert into test values(1,'erwe');
Query OK, 1 row affected (0.01 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into oo values (44,current_date);
Query OK, 1 row affected (0.02 sec)

mysql> insert into oo values (44,current_date);
Query OK, 1 row affected (0.00 sec)

mysql> insert into oo values (44,current_date);
Query OK, 1 row affected (0.01 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from test;
+------+------+
| jj | kk |
+------+------+
| 1 | erwe |
| 1 | erwe |
| 1 | erwe |
+------+------+
3 rows in set (0.00 sec)

mysql> select * from oo;
+------+------------+
| id | ll |
+------+------------+
| 44 | 2016-04-08 |
| 44 | 2016-04-08 |
| 44 | 2016-04-08 |
+------+------------+
3 rows in set (0.00 sec

mysql> select * from t_t1;
+-------+
| name |
+-------+
| zhang |
+-------+
1 row in set (0.00 sec)

二、基础部署

1、源库配置数据类型转换

GGSCI (n1) 5> edit params defgen

DEFSFILE ./dirdef/source.def, PURGE
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD Password@1
TABLE mydb1.*;

root@n1:/opt/app/OGG_MYSQL# ./defgen paramfile dirprm/defgen.prm

***********************************************************************
Oracle GoldenGate Table Definition Generator for MySQL
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230
Linux, x64, 64bit (optimized), MySQL Enterprise on Apr 23 2012 05:11:37

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

Starting at 2016-04-08 09:49:13
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
Node: n1
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: 4829

***********************************************************************
** Running with the following parameters **
***********************************************************************
DEFSFILE ./dirdef/source.def, PURGE
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD **********
TABLE mydb1.*;
Expanding wildcard mydb1.*:

Retrieving definition for mydb1.oo
Retrieving definition for mydb1.t_t1
Retrieving definition for mydb1.test

Definitions generated for 3 tables in ./dirdef/source.def

2、将转换配置文件拷贝到目标服务器(Oracle服务端)
scp ./dirdef/source.def 172.16.57.27:/opt/app/OGG_MYSQL/dirdef/source.def
root@n3:/opt/app/OGG_MYSQL# chown -R oracle:oinstall /opt/app/OGG_MYSQL/dirdef/source.def

3、配置manager进程

源端(mysql)配置
edit params mgr

PORT 3310
dynamicportlist 9901-9920,9930
autostart er *
autorestart er *,retries 4,waitminutes 4
startupvalidationdelay 5
purgeoldextracts /opt/app/OGG_MYSQL/dirdat/*,usecheckpoints,minkeephours 2

GGSCI (n1) 16> start mgr
Manager started.

GGSCI (n1) 17> info mgr
Manager is running (IP port n1.3310).

目标端(Oracle)配置
edit params mgr

PORT 3311
ACCESSRULE, PROG REPLICAT, IPADDR 172.16.57.26, ALLOW
dynamicportlist 7810-7820,7830
autostart er r*
autorestart er r*,retries 4,waitminutes 4
startupvalidationdelay 5
purgeoldextracts /opt/app/OGG_MYSQL/dirdat/rt*,usecheckpoints,minkeephours 2

GGSCI (n2) 5> start mgr
Manager started.

GGSCI (n2) 6> info mgr
Manager is running (IP port n2.3311).

注意:ACCESSRULE, PROG REPLICAT, IPADDR 172.16.57.26, ALLOW 是12c新版本新加的功能

4、目标端创建表结构

SQL> create user ogg identified by ogg;
SQL> grant connect,resource,dba to ogg;
SQL> create user mysql identified by mysql;

User created.

SQL> grant connect,resource to mysql
2 ;

Grant succeeded.

SQL> grant create view,create synonym to mysql;

Grant succeeded.

SQL> conn mysql/mysql
Connected.

SQL> create table t_t1(name varchar2(10));

SQL> create table test (jj number,kk varchar2(20));

SQL> create table oo (id number,ll date);

三、配置数据初始化(直接加载方式)

1、源端配置initial load capture

ADD EXTRACT EINI, SOURCEISTABLE

2、编辑配置capture 参数

EDIT PARAMS EINI

EXTRACT EINI
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD Password@1
RMTHOST 172.16.57.27, MGRPORT 3311
RMTTASK REPLICAT, GROUP RINI
TABLE mydb1.*;

MGRPORT 也可后来编辑

3、目标端配置initial load delivery

ADD REPLICAT RINI, SPECIALRUN

4、编辑delivery参数

EDIT PARAMS RINI

REPLICAT RINI
USERID ogg, PASSWORD ogg
SOURCEDEFS ./dirdef/source.def
DISCARDFILE ./dirrpt/RINI.dsc, PURGE
MAP mydb1.*, TARGET mysql.*;

四、配置数据同步

1、源端配置extract进程:
ADD EXTRACT EX1, TRANLOG, BEGIN NOW
ADD RMTTRAIL /opt/app/OGG_MYSQL/dirdat/zz, EXTRACT EX1

edit params EX1

EXTRACT EX1
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD Password@1
rmthost 172.16.57.27, mgrport 3321
rmttrail /opt/app/OGG_MYSQL/dirdat/zz
discardfile /opt/app/OGG_MYSQL/dirrpt/trail.dsc,append,megabytes 100
TRANLOGOPTIONS ALTLOGDEST /var/lib/mysql/mysql-bin.index
TABLE mydb1.*;

注意这里的日志进程必须和,replica进程的日志路径对应/opt/app/OGG_MYSQL/dirdat/zz
启动:
GGSCI (n1) 87> start EX1

Sending START request to MANAGER ...
EXTRACT EX1 starting

GGSCI (n1) 88> view report EX1

***********************************************************************
Oracle GoldenGate Capture for MySQL
Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401
Linux, x64, 64bit (optimized), MySQL Enterprise on Dec 11 2015 17:40:15

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

Starting at 2016-04-08 15:35:04
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
Node: n1
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: 133731

Description:

***********************************************************************
** Running with the following parameters **
***********************************************************************

2016-04-08 15:35:04 INFO OGG-03059 Operating system character set identified as UTF-8.

2016-04-08 15:35:04 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.
EXTRACT ex1
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD ***
rmthost 172.16.57.27, mgrport 3321
rmttrail /opt/app/OGG_MYSQL/dirdat/zz
discardfile /opt/app/OGG_MYSQL/dirrpt/trail.dsc,append,megabytes 100
TRANLOGOPTIONS ALTLOGDEST /var/lib/mysql/mysql-bin.index
TABLE mydb1.*;

2016-04-08 15:35:04 INFO OGG-01851 filecaching started: thread ID: 140669416716032.

2016-04-08 15:35:04 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:
/opt/app/OGG_MYSQL/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)
CACHEPAGEOUTSIZE (default): 8M
PROCESS VM AVAIL FROM OS (min): 128G
CACHESIZEMAX (strict force to disk): 96G

Database Version:
MySQL
Server Version: 5.7.11-log
Client Version: 5.6.14
Host Connection: Localhost via UNIX socket
Protocol Version: 10

Database Language and Character Set:
CLIENT CHARACTER SET = "utf8mb4"
SERVER CHARACTER SET = "latin1"
DATABASE CHARACTER SET = "latin1"
LOCALE INFORMATION = "en"
DATABASE COLLATION = "casesensitive"

2016-04-08 15:35:14 INFO OGG-01226 Socket buffer size set to 27985 (flush size 27985).

2016-04-08 15:35:14 INFO OGG-01052 No recovery is required for target file /opt/app/OGG_MYSQL/dirdat/zz000000000, at RBA 0 (file not opened).

2016-04-08 15:35:14 INFO OGG-01478 Output file /opt/app/OGG_MYSQL/dirdat/zz is using format RELEASE 12.2.

2016-04-08 15:35:14 INFO OGG-00182 VAM API running in single-threaded mode.

2016-04-08 15:35:14 INFO OGG-01515 Positioning to begin time Apr 8, 2016 3:33:34 PM.

INFO !! using index file /var/lib/mysql/mysql-bin.index

***********************************************************************
** Run Time Messages **
***********************************************************************

##注意:
##如果extract进程没有设置rmttrail,可以进行如下操作,推荐使用上面的配置,DUMP同步数据有延迟!!!
##======================================================================================================
##1、源段配置extract
##
##GGSCI (n1) 12>ADD EXTRACT EMSQ, TRANLOG, BEGIN NOW
##
##GGSCI (n1) 13>edit params EMSQ
##EXTRACT EMSQ
##SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD Password@1
##EXTTRAIL ./dirdat/rt
##TRANLOGOPTIONS ALTLOGDEST /var/lib/mysql/mysql-bin.index
##TABLE mydb1.*;
##
##将extract进程和本地trail关联
##
##GGSCI (n1) 14> ADD EXTTRAIL ./dirdat/rt,extract EMSQ
##EXTTRAIL added.
##
##
##2、添加data pump进程
##
##
##GGSCI (n1) 15> ADD EXTRACT DP01,EXTTRAILSOURCE ./dirdat/rt,BEGIN NOW
##EXTRACT added.
##
##编辑DP01参数
##GGSCI (n1) 16> edit params DP01
##EXTRACT DP01
##SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD Password@1
##RMTHOST 172.16.57.27, MGRPORT 3311
##RMTTRAIL /opt/app/OGG_MYSQL/dirdat/rt
##PASSTHRU
##TABLE mydb1.*;
##
##定义remote trail与data pump的链接关系
##
##GGSCI (n1) 17> add rmttrail /opt/app/OGG_MYSQL/dirdat/rt,extract DP01
##RMTTRAIL added.
##
##
##3、启动extract进程和data pump进程
##
##启动extract:
##GGSCI (n1) 18> start EMSQ
##
##Sending START request to MANAGER ...
##EXTRACT EMSQ starting
##
##
##GGSCI (n1) 9> view report EMSQ
##
##
##***********************************************************************
## Oracle GoldenGate Capture for MySQL
## Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401
## Linux, x64, 64bit (optimized), MySQL Enterprise on Dec 11 2015 17:40:15
##
##Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
##
##
## Starting at 2016-04-08 12:46:53
##***********************************************************************
##
##Operating System Version:
##Linux
##Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
##Node: n1
##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: 61129
##
##Description:
##
##***********************************************************************
##** Running with the following parameters **
##***********************************************************************
##
##2016-04-08 12:46:53 INFO OGG-03059 Operating system character set identified as UTF-8.
##
##2016-04-08 12:46:53 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.
##EXTRACT EMSQ
##SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD ***
##EXTTRAIL ./dirdat/rt
##TRANLOGOPTIONS ALTLOGDEST /var/lib/mysql/mysql-bin.index
##TABLE mydb1.*;
##
##2016-04-08 12:46:53 INFO OGG-01851 filecaching started: thread ID: 140635606607616.
##
##2016-04-08 12:46: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:
## /opt/app/OGG_MYSQL/dirtmp.
##
##CACHEMGR virtual memory values (may have been adjusted)
##CACHEPAGEOUTSIZE (default): 8M
##PROCESS VM AVAIL FROM OS (min): 128G
##CACHESIZEMAX (strict force to disk): 96G
##
##Database Version:
##MySQL
##Server Version: 5.7.11-log
##Client Version: 5.6.14
##Host Connection: Localhost via UNIX socket
##Protocol Version: 10
##
##Database Language and Character Set:
##CLIENT CHARACTER SET = "utf8mb4"
##SERVER CHARACTER SET = "latin1"
##DATABASE CHARACTER SET = "latin1"
##LOCALE INFORMATION = "en"
##DATABASE COLLATION = "casesensitive"
##
##2016-04-08 12:46:53 INFO OGG-01052 No recovery is required for target file ./dirdat/rt000000000, at RBA 0 (file not opened).
##
##2016-04-08 12:46:53 INFO OGG-01478 Output file ./dirdat/rt is using format RELEASE 12.2.
##
##2016-04-08 12:46:53 INFO OGG-00182 VAM API running in single-threaded mode.
##
##2016-04-08 12:46:53 INFO OGG-01515 Positioning to begin time Apr 8, 2016 12:45:29 PM.
##
## INFO !! using index file /var/lib/mysql/mysql-bin.index
##
##***********************************************************************
##** Run Time Messages **
##***********************************************************************
##
##
##启动data pump:
##GGSCI (n1) 15> start DP01
##
##Sending START request to MANAGER ...
##EXTRACT DP01 starting
##
##GGSCI (n1) 16> view report DP01
##
##
##***********************************************************************
## Oracle GoldenGate Capture for MySQL
## Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401
## Linux, x64, 64bit (optimized), MySQL Enterprise on Dec 11 2015 17:40:15
##
##Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
##
##
## Starting at 2016-04-08 12:49:08
##***********************************************************************
##
##Operating System Version:
##Linux
##Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
##Node: n1
##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: 61798
##
##Description:
##
##***********************************************************************
##** Running with the following parameters **
##***********************************************************************
##
##2016-04-08 12:49:08 INFO OGG-03059 Operating system character set identified as UTF-8.
##
##2016-04-08 12:49:08 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.
##EXTRACT DP01
##SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD ***
##RMTHOST 172.16.57.27, MGRPORT 3321
##RMTTRAIL /opt/app/OGG_MYSQL/dirdat/rt
##PASSTHRU
##TABLE mydb1.*;
##
##2016-04-08 12:49:08 INFO OGG-01851 filecaching started: thread ID: 140351121643264.
##
##2016-04-08 12:49:08 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:
## /opt/app/OGG_MYSQL/dirtmp.
##
##CACHEMGR virtual memory values (may have been adjusted)
##CACHEPAGEOUTSIZE (default): 8M
##PROCESS VM AVAIL FROM OS (min): 128G
##CACHESIZEMAX (strict force to disk): 96G
##
##Database Version:
##MySQL
##Server Version: 5.7.11-log
##Client Version: 5.6.14
##Host Connection: Localhost via UNIX socket
##Protocol Version: 10
##
##Database Language and Character Set:
##CLIENT CHARACTER SET = "utf8mb4"
##SERVER CHARACTER SET = "latin1"
##DATABASE CHARACTER SET = "latin1"
##LOCALE INFORMATION = "en"
##DATABASE COLLATION = "casesensitive"
##
##2016-04-08 12:49:08 INFO OGG-02243 Opened trail file /opt/app/OGG_MYSQL/dirdat/rt000000000 at 2016-04-08 12:49:08.921471.
##
##2016-04-08 12:49:08 WARNING OGG-01015 Positioning with begin time: Apr 8, 2016 12:46:22 PM, waiting for data: at extseqno 0, extrba 0.
##
##2016-04-08 12:49:18 INFO OGG-01226 Socket buffer size set to 27985 (flush size 27985).
##
##2016-04-08 12:49:18 INFO OGG-01052 No recovery is required for target file /opt/app/OGG_MYSQL/dirdat/rt000000000, at RBA 0 (file not opened).
##
##2016-04-08 12:49:18 INFO OGG-01478 Output file /opt/app/OGG_MYSQL/dirdat/rt is using format RELEASE 12.2.
##
##***********************************************************************
##** Run Time Messages **
##***********************************************************************
##
##
##2016-04-08 12:49:18 INFO OGG-02243 Opened trail file /opt/app/OGG_MYSQL/dirdat/rt000000000 at 2016-04-08 12:49:18.957109.
##
##
##GGSCI (n1) 22> info all
##
##Program Status Group Lag at Chkpt Time Since Chkpt
##
##MANAGER RUNNING
##EXTRACT RUNNING DP01 00:00:00 00:00:01
##EXTRACT RUNNING EMSQ 00:00:00 00:00:08
##==============================================================================================================================================

4、目标端添加checkpiont表

GGSCI (n2) 8> DBLOGIN USERID ogg, PASSWORD ogg
Successfully logged into database.

GGSCI (n2) 9> ADD CHECKPOINTTABLE ogg.chkpnt_mysql
Successfully created checkpoint table ogg.chkpnt_mysql.

5、目标端创建replicat进程

实际操作:

GGSCI (n2) 11> ADD REPLICAT RORA, EXTTRAIL ./dirdat/zz,CHECKPOINTTABLE ogg.chkpnt_mysql
REPLICAT added.

注意这里呼应前面的./dirdat/zz路径
编辑Replicat参数文件
GGSCI (n2) 12> edit params RORA

REPLICAT RORA
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
SOURCEDEFS ./dirdef/source.def
DISCARDFILE ./dirrpt/RORA.DSC, append,megabytes 10
MAP mydb1.*, TARGET mysql.*;

五、启动初始化数据装载

1、源端启动initial进程

GGSCI (n1) 17> START EXTRACT EINI

Sending START request to MANAGER ...

ERROR: Cannot create process '/opt/app/OGG_MYSQL/extract'. Child process is no longer alive
.

2016-04-08 12:51:41 WARNING OGG-01742 Command sent to MGR MGR returned with an ERROR response.

解决办法:
12c新加功能,在target的mgr进程中添加认证信息:
ACCESSRULE, PROG REPLICAT, IPADDR 172.16.57.26, ALLOW

继续报错:
WARNING OGG-01194 EXTRACT task RINI abended : Operation not supported because enable_goldengate_replication is not set to true.
解决办法:在oracle中把参数设置成true。
SQL> conn / as sysdba
Connected.
SQL> alter system set enable_goldengate_replication=true;

System altered.

再次启动:
GGSCI (n1) 28> start EINI

Sending START request to MANAGER ...
EXTRACT EINI starting

GGSCI (n1) 29> view report EINI

2016-04-08 13:14:58 INFO OGG-01017 Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is used.

***********************************************************************
Oracle GoldenGate Capture for MySQL
Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401
Linux, x64, 64bit (optimized), MySQL Enterprise on Dec 11 2015 17:40:15

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

Starting at 2016-04-08 13:14:58
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
Node: n1
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: 70582

Description:

***********************************************************************
** Running with the following parameters **
***********************************************************************

2016-04-08 13:14:58 INFO OGG-03059 Operating system character set identified as UTF-8.

2016-04-08 13:14:58 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.
EXTRACT EINI
SOURCEDB mydb1@localhost:3306, USERID ogg, PASSWORD ***
RMTHOST 172.16.57.27, MGRPORT 3321
RMTTASK REPLICAT, GROUP RINI
TABLE mydb1.*;

2016-04-08 13:14:58 INFO OGG-06508 Wildcard MAP (TABLE) resolved (entry mydb1.*): TABLE "mydb1"."oo".

2016-04-08 13:14:58 INFO OGG-06509 Using the following key columns for source table mydb1.oo: id, ll.

2016-04-08 13:14:58 INFO OGG-06508 Wildcard MAP (TABLE) resolved (entry mydb1.*): TABLE "mydb1"."t_t1".

2016-04-08 13:14:58 INFO OGG-06509 Using the following key columns for source table mydb1.t_t1: name.

2016-04-08 13:14:58 INFO OGG-06508 Wildcard MAP (TABLE) resolved (entry mydb1.*): TABLE "mydb1"."test".

2016-04-08 13:14:58 INFO OGG-06509 Using the following key columns for source table mydb1.test: jj, kk.

2016-04-08 13:14:58 INFO OGG-01851 filecaching started: thread ID: 139816878466816.

2016-04-08 13:14:58 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:
/opt/app/OGG_MYSQL/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)
CACHEPAGEOUTSIZE (default): 8M
PROCESS VM AVAIL FROM OS (min): 128G
CACHESIZEMAX (strict force to disk): 96G

Database Version:
MySQL
Server Version: 5.7.11-log
Client Version: 5.6.14
Host Connection: Localhost via UNIX socket
Protocol Version: 10

Database Language and Character Set:
CLIENT CHARACTER SET = "utf8mb4"
SERVER CHARACTER SET = "latin1"
DATABASE CHARACTER SET = "latin1"
LOCALE INFORMATION = "en"
DATABASE COLLATION = "casesensitive"

GGSCI (n1) 30>

GGSCI (n1) 30>

GGSCI (n1) 30> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING
EXTRACT RUNNING DP01 00:00:00 00:00:01
EXTRACT RUNNING EMSQ 00:00:00 00:00:06

查看目标端delivery进程信息:

GGSCI (n2 as ogg@emtest) 27> view report RINI

***********************************************************************
Oracle GoldenGate Delivery for Oracle
Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Dec 12 2015 01:27:04

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

Starting at 2016-04-08 13:14:58
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
Node: n2
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: 12583

Description:

2016-04-08 13:15:08 WARNING OGG-02904 Replication of PARTIAL XML containing NCHAR/NVARCHAR/NCLOB data may cause divergence.

***********************************************************************
** Running with the following parameters **
***********************************************************************

2016-04-08 13:15:08 INFO OGG-03059 Operating system character set identified as UTF-8.

2016-04-08 13:15:08 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.

2016-04-08 13:15:08 INFO OGG-03528 The source database character set, as determined from the table definition file, is ISO-8859-1.
REPLICAT RINI
USERID ogg, PASSWORD ***
SOURCEDEFS ./dirdef/source.def
DISCARDFILE ./dirrpt/RINI.dsc, PURGE
MAP mydb1.*, TARGET mysql.*;

2016-04-08 13:15:08 INFO OGG-06451 Triggers will be suppressed by default.

2016-04-08 13:15:08 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:
/opt/app/OGG_MYSQL/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)
CACHEPAGEOUTSIZE (default): 4M
PROCESS VM AVAIL FROM OS (min): 4G
CACHESIZEMAX (strict force to disk): 3.41G

Database Version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Database Language and Character Set:
NLS_LANGUAGE = "AMERICAN"
NLS_TERRITORY = "AMERICA"
NLS_CHARACTERSET = "AL32UTF8"

***********************************************************************
** Run Time Messages **
***********************************************************************

2016-04-08 13:15:08 WARNING OGG-02761 Source definitions file, ./dirdef/source.def, is ignored because trail file contains table definitions.

2016-04-08 13:15:08 INFO OGG-06506 Wildcard MAP resolved (entry mydb1.*): MAP "mydb1"."oo", TARGET mysql."oo".

2016-04-08 13:15:11 WARNING OGG-06439 No unique key is defined for table OO. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to
define the key.

2016-04-08 13:15:11 INFO OGG-02756 The definition for table mydb1.oo is obtained from the trail file.

2016-04-08 13:15:11 INFO OGG-06511 Using following columns in default map by name: ID, LL.

2016-04-08 13:15:11 INFO OGG-06510 Using the following key columns for target table MYSQL.OO: ID, LL.

2016-04-08 13:15:11 INFO OGG-03010 Performing implicit conversion of column data from character set ISO-8859-1 to UTF-8.

2016-04-08 13:15:11 INFO OGG-06506 Wildcard MAP resolved (entry mydb1.*): MAP "mydb1"."t_t1", TARGET mysql."t_t1".

2016-04-08 13:15:11 WARNING OGG-06439 No unique key is defined for table T_T1. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used
to define the key.

2016-04-08 13:15:11 INFO OGG-02756 The definition for table mydb1.t_t1 is obtained from the trail file.

2016-04-08 13:15:11 INFO OGG-06511 Using following columns in default map by name: NAME.

2016-04-08 13:15:11 INFO OGG-06510 Using the following key columns for target table MYSQL.T_T1: NAME.

2016-04-08 13:15:11 INFO OGG-06506 Wildcard MAP resolved (entry mydb1.*): MAP "mydb1"."test", TARGET mysql."test".

2016-04-08 13:15:11 WARNING OGG-06439 No unique key is defined for table TEST. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used
to define the key.

2016-04-08 13:15:11 INFO OGG-02756 The definition for table mydb1.test is obtained from the trail file.

2016-04-08 13:15:11 INFO OGG-06511 Using following columns in default map by name: JJ, KK.

2016-04-08 13:15:11 INFO OGG-06510 Using the following key columns for target table MYSQL.TEST: JJ, KK.

***********************************************************************
* ** Run Time Statistics ** *
***********************************************************************

Report at 2016-04-08 13:15:16 (activity since 2016-04-08 13:15:11)

From Table mydb1.oo to MYSQL.OO:
# inserts: 3
# updates: 0
# deletes: 0
# discards: 0
From Table mydb1.t_t1 to MYSQL.T_T1:
# inserts: 1
# updates: 0
# deletes: 0
# discards: 0
From Table mydb1.test to MYSQL.TEST:
# inserts: 3
# 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) = 4M
pageout eligible size = 4M

================================================================================
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 | 512M: 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 | 512M: 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 = 11 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
10 64M 0 0 0 0

================================================================================
RUNTIME STATS FOR CACHE POOL #0
POOL INFO group: rini id: p12583_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 | 512M: 0

================================================================================
CUMULATIVE STATS FOR CACHE POOL #0 (PREVIOUS RUNS ONLY)
POOL INFO group: rini id: p12583_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 | 512M: 0

根据报告,数据已经初始化成功了,也可以通过Oracle数据库去验证:
SQL> conn mysql/mysql
Connected.
SQL> select * from t_t1;

NAME
------------------------------
wang

SQL> select * from test;

JJ KK
---------- ------------------------------------------------------------
2 erwe
2 erwe
2 erwe

SQL> select * from oo;

ID LL
---------- ---------------
44 08-APR-16
44 08-APR-16
44 08-APR-16

六、启动数据同步

1、初始化过程中,产生的新数据是否同步?
在启动同步之前,在mysql库中做如下操作:
use mydb1
insert into t_t1 values('zhang');
update test set jj=3 where kk='erwe';
delete from t_t1 where name='wang';
truncate table oo;
commit;

mysql查看如下:
mysql> select * from t_t1;
+-------+
| name |
+-------+
| zhang |
+-------+
1 row in set (0.00 sec)

mysql> select * from oo;
Empty set (0.00 sec)

mysql> select * from test;
+------+------+
| jj | kk |
+------+------+
| 3 | erwe |
| 3 | erwe |
| 3 | erwe |
+------+------+
3 rows in set (0.00 sec)

2、启动同步进程(目标端replicat进程)在目标端执行
GGSCI (n2 as ogg@emtest) 28> start RORA

Sending START request to MANAGER ...
REPLICAT RORA starting
此时报错
查看错误信息

2016-04-12 15:53:24 WARNING OGG-02904 Replication of PARTIAL XML containing NCHAR/NVARCHAR/NCLOB data may cause divergence.

***********************************************************************
** Running with the following parameters **
***********************************************************************

2016-04-12 15:53:24 INFO OGG-03059 Operating system character set identified as UTF-8.

2016-04-12 15:53:24 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.

2016-04-12 15:53:24 INFO OGG-03528 The source database character set, as determined from the table definition file, is ISO-8859-1.、

以上红色报错没有关系
***********************************************************************
** Run Time Messages **
***********************************************************************
没有信息

GGSCI (n2 as ogg@emtest) 29> view report RORA

***********************************************************************
Oracle GoldenGate Delivery for Oracle
Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Dec 12 2015 01:27:04

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

Starting at 2016-04-08 13:24:48
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Oct 15 04:27:16 UTC 2014, Release 2.6.32-504.el6.x86_64
Node: n2
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: 14851

Description:

2016-04-08 13:24:48 WARNING OGG-02904 Replication of PARTIAL XML containing NCHAR/NVARCHAR/NCLOB data may cause divergence.

***********************************************************************
** Running with the following parameters **
***********************************************************************

2016-04-08 13:24:48 INFO OGG-03059 Operating system character set identified as UTF-8.

2016-04-08 13:24:48 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.

2016-04-08 13:24:48 INFO OGG-03528 The source database character set, as determined from the table definition file, is ISO-8859-1.
REPLICAT RORA
USERID ogg, PASSWORD ***
HANDLECOLLISIONS
SOURCEDEFS ./dirdef/source.def
DISCARDFILE ./dirrpt/RORA.DSC, append,megabytes 10
MAP mydb1.*, TARGET mysql.*;

2016-04-08 13:24:48 INFO OGG-06451 Triggers will be suppressed by default.

2016-04-08 13:24:48 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:
/opt/app/OGG_MYSQL/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)
CACHEPAGEOUTSIZE (default): 4M
PROCESS VM AVAIL FROM OS (min): 4G
CACHESIZEMAX (strict force to disk): 3.41G

Database Version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Database Language and Character Set:
NLS_LANGUAGE = "AMERICAN"
NLS_TERRITORY = "AMERICA"
NLS_CHARACTERSET = "AL32UTF8"

***********************************************************************
** Run Time Messages **
***********************************************************************

2016-04-08 13:24:48 INFO OGG-02243 Opened trail file ./dirdat/rt000000000 at 2016-04-08 13:24:48.817489.

2016-04-08 13:24:48 WARNING OGG-02761 Source definitions file, ./dirdef/source.def, is ignored because trail file ./dirdat/rt000000000 contains table definitions.

2016-04-08 13:24:48 INFO OGG-03506 The source database character set, as determined from the trail file, is ISO-8859-1.

2016-04-08 13:24:48 INFO OGG-06506 Wildcard MAP resolved (entry mydb1.*): MAP "mydb1"."t_t1", TARGET mysql."t_t1".

2016-04-08 13:24:48 WARNING OGG-06439 No unique key is defined for table T_T1. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used
to define the key.

2016-04-08 13:24:48 INFO OGG-02756 The definition for table mydb1.t_t1 is obtained from the trail file.

2016-04-08 13:24:48 INFO OGG-06511 Using following columns in default map by name: NAME.

2016-04-08 13:24:48 INFO OGG-06510 Using the following key columns for target table MYSQL.T_T1: NAME.

2016-04-08 13:24:48 INFO OGG-03010 Performing implicit conversion of column data from character set ISO-8859-1 to UTF-8.

2016-04-08 13:24:48 INFO OGG-06506 Wildcard MAP resolved (entry mydb1.*): MAP "mydb1"."test", TARGET mysql."test".

2016-04-08 13:24:48 WARNING OGG-06439 No unique key is defined for table TEST. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used
to define the key.

2016-04-08 13:24:48 INFO OGG-02756 The definition for table mydb1.test is obtained from the trail file.

2016-04-08 13:24:48 INFO OGG-06511 Using following columns in default map by name: JJ, KK.

2016-04-08 13:24:48 INFO OGG-06510 Using the following key columns for target table MYSQL.TEST: JJ, KK.

Oracle验证如下:

SQL> select * from t_t1;

NAME
------------------------------
zhang

SQL> select * from test;

JJ KK
---------- ------------------------------------------------------------
3 erwe
3 erwe
3 erwe

SQL> select * from oo;

ID LL
---------- ---------------
44 08-APR-16
44 08-APR-16
44 08-APR-16

根据结果:
1、数据库的DML操作都同步到Oracle中了
2、truncate(DDL)操作无法同步

target 端
send RORA ,nohandlecollisions
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: