goldengate 12.3 实现mysql数据及DDL实时同步

以下环境在mysql 5.7上完成。
set mysql_home=mysql安装路径
set path=%mysql_home%\bin;%path%
首先要准备mysql的启动,可参考:http://silentwu.iteye.com/blog/2308722
由于需要使用OGG解析日志,所以需要在my.ini/my.cnf中设置如下参数
log-bin=u:/soft/mysql/5.7/mysql-5.7.19-winx64/logs/log-bin
binlog-ignore-db=oggddl
binlog_format=row

 

如果需要同步DDL,则需要在OGG安装目录下执行:
ddl_install.cmd/sh install root "root_password" 3306

 

重启mysql,使参数生效。
 

准备测试库表和用户

 
--源库
create database testdb charset utf8;
use testdb;
create table tb1(id int primary key, name varchar(50));

 

 

--目标库
create database tgtdb charset utf8;
use tgtdb;
create table tgtdb.tb1(id int primary key, name varchar(50));
 

--同步用户
create user 'ogg'@'%' identified by 'ogg';
GRANT ALL PRIVILEGES ON *.* TO 'ogg'@'%' IDENTIFIED BY 'ogg' WITH GRANT OPTION; 
FLUSH   PRIVILEGES;

以下配置在同一节点上完成,所以不需要传输进程。

抽取进程参数ex1.prm
extract ex1
sourcedb testdb@localhost, userid ogg, password ogg
TRANLOGOPTIONS ALTLOGDEST "u:\\soft\\mysql\\5.7\\mysql-5.7.19-winx64\\logs\\log-bin.index"
exttrail ./dirdat/ea
ddl include mapped
table testdb.*;

 

 

add extract ex1, tranlog, begin now
add exttrail ./dirdat/ea, extract ex1
 

投递进程参数re1.prm

replicat re1
targetdb tgtdb@localhost, userid ogg, password ogg
AssumeTargetDefs
map testdb.*, target tgtdb.*;


add replicat re1, exttrail ./dirdat/ea, nodbcheckpoint

-- DML测试
insert into testdb.tb1 values(1,'bbc');
insert into testdb.tb1 values(2,'bdsfbc');
 

- DDL 测试
create table testdb.tb2(id int primary key, name varchar(50));
alter table testdb.tb2 add age int;
insert into testdb.tb2 values(2, 'cdl',40);

 

posted @ 2017-08-22 08:40  margiex  阅读(2473)  评论(0编辑  收藏  举报