mysql goldengate同步 簡單配置

selectshen發表於2015-07-03
----主機資訊
os:cent os 6.5
host: ct6505/192.108.56.115  
      ct6506/192.108.56.116  
MySQL:5.6.24
Goldengate:12.1.2  

----安裝MySQL
--ct6505,ct6506
[root@ct6505/6 ~]# yum remove mysql-libs-5.1.71-1.el6.x86_64
[root@ct6505/6 ~]# yum install libaio
[root@ct6505/6 ~]# yum  install perl
[root@ct6505/6 ~]#  ls MySQL-*
MySQL-client-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm
[root@ct6505/6 ~]# rpm -ivh MySQL-*

----配置MySQL
--ct6505,ct6506
[root@ct6505/6 mysql]# cat /usr/my.cnf
[mysqld]
log_bin=/var/lib/mysql/mysql01.log
log_error=/var/lib/mysql/mysql01.err

innodb_flush_log_at_trx_commit=1
sync_binlog=1
binlog_format=row
innodb_support_xa=1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[root@ct6505/6 ~]#  mysql -uroot -p
mysql> SET PASSWORD = PASSWORD('system');
mysql> use mysql;
mysql> update user set host='%' where host='localhost';
mysql> flush privileges;
mysql> create table test.test1(a int); --測試同步用

--ct6506
mysql> create database ogg;

--ct6505,ct6506
[root@ct6505/6 ~]#ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

----安裝goldendate
--ct6505,ct6506
[root@ct6505/6 ggmysql]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.108.56.115  ct6505
192.108.56.116  ct6506

[root@ct6505/6 ~]# mkdir /ggmysql
[root@ct6505/6 ~]# mv ggs_Linux_x64_MySQL_64bit.tar /ggmysql/
[root@ct6505/6 ~]# cd /ggmysql/
[root@ct6505/6 ggmysql]# tar -xvf ggs_Linux_x64_MySQL_64bit.tar

----配置goldengate
--ct6505
[root@ct6505 ggmysql]# ./ggsci
GGSCI (ct6505) 1> create subdirs
GGSCI (ct6505) 2> edit params mgr
port 7809
DYNAMICPORTLIST  7840-7940

GGSCI (ct6505) 3> add extract ext1,vam,begin now
GGSCI (ct6505) 4> add exttrail /ggmysql/dirdat/r1,extract ext1
GGSCI (ct6505) 5> edit params ext1
extract ext1
sourcedb test@localhost:3306,userid root,password system
tranlogoptions altlogdest /var/lib/mysql/mysql01.index
exttrail /ggmysql/dirdat/r1
dynamicresolution
gettruncates
table test.*;

GGSCI (ct6505) 6>  add extract pump1,exttrailsource /ggmysql/dirdat/r1,begin now
GGSCI (ct6505) 7> add rmttrail /ggmysql/dirdat/r1 extract pump1
GGSCI (ct6505) 8> edit params pump1
extract pump1
rmthost 192.108.56.116,mgrport 7809
rmttrail /ggmysql/dirdat/r1
passthru
gettruncates
table test.*;

GGSCI (ct6506) 9> start mgr
GGSCI (ct6506) 10> start ext1
GGSCI (ct6506) 11> start pump1
GGSCI (ct6506) 12> info all


--ct6506
[root@ct6506 ggmysql]# ./ggsci
GGSCI (ct6506) 1> create subdirs
GGSCI (ct6506) 2> edit params ./GLOBALS
checkpointtable ogg.chkpoint

GGSCI (ct6506) 3> edit params mgr
port 7809
DYNAMICPORTLIST  7840-7940

GGSCI (ct6506) 4> dblogin sourcedb test@192.108.56.116:3306,userid root,password system
GGSCI (ct6506) 5> add checkpointtable ogg.chkpoint
GGSCI (ct6506) 6> add replicat rep1 exttrail /ggmysql/dirdat/r1,begin now,checkpointtable  ogg.chkpoint
GGSCI (ct6506) 7> edit params rep1
replicat rep1
dboptions host localhost,connectionport 3306
targetdb test,userid root,password system
assumetargetdefs
reperror default,discard
discardfile /ggmysql/dirrpt/b_rep1.dsc, APPEND, MEGABYTES 100
gettruncates
map test.*,target test.*;

GGSCI (ct6506) 8> start mgr
GGSCI (ct6506) 9> start rep1
GGSCI (ct6506) 10> info all

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-1721809/,如需轉載,請註明出處,否則將追究法律責任。

相關文章