以下環境在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中設置如下參數
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
binlog-ignore-db=oggddl
binlog_format=row
如果需要同步DDL,則需要在OGG安裝目錄下執行:
ddl_install.cmd/sh install root "root_password" 3306
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)); --同步用戶 |
以下配置在同一節點上完成,所以不需要傳輸進程。
抽取進程參數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
add exttrail ./dirdat/ea, extract ex1
投遞進程參數re1.prm
replicat re1 |
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);