怎么搭建OGG12cMySQLtoMySQL-创新互联

本篇内容介绍了“怎么搭建OGG 12c MySQL to MySQL”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

东丰网站建设公司创新互联,东丰网站设计制作,有大型网站制作公司丰富经验。已为东丰成百上千家提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的东丰做网站的公司定做!

安装包下载
下载最新的OGG FOR MySQL,这里使用的是
ggs_121210_Linux_x64_MySQL_64bit.zip 
官方下载地址:
http://www.oracle.com/technetwork/cn/middleware/goldengate/downloads/index.html

source和target端的OGG安装
创建OGG主目录
mkdir /ogg
解压安装包,会得到一个tar文件
unzip ggs_121210_Linux_x64_MySQL_64bit.zip 
将tar文件移至OHGG主目录,并解压即可
mv ggs_Linux_x64_MySQL_64bit.tar /ogg/
tar xvf ggs_Linux_x64_MySQL_64bit.tar 
修改环境变量
vi ~/.bash_profile
加入如下三个变量
export GGHOME=/ogg
export PATH=$PATH:$GGHOME
export LD_LIBRARY_PATH=/ogg:$LD_LIBRARY_PATH

登入OGG创建OGG的相关目录
[root@20_138-Mysql_Test1 ogg]# ./ggsci 
Oracle GoldenGate Command Interpreter FOR MySQL
VERSION 12.1.2.1.0 OGGCORE_12.1.2.1.0_PLATFORMS_140920.0203
Linux, x64, 64BIT (optimized), MySQL Enterprise ON Sep 20 2014 03:43:22
Operating system CHARACTER SET IDENTIFIED AS UTF-8.
Copyright (C) 1995, 2014, Oracle AND/OR its affiliates. ALL rights reserved.

GGSCI (20_138-Mysql_Test1) 1> CREATE subdirs
Creating subdirectories under current DIRECTORY /ogg
Parameter files                /ogg/dirprm: already EXISTS
Report files                   /ogg/dirrpt: created
Checkpoint files               /ogg/dirchk: created
PROCESS STATUS files           /ogg/dirpcs: created
SQL script files               /ogg/dirsql: created
DATABASE definitions files     /ogg/dirdef: created
EXTRACT DATA files             /ogg/dirdat: created
TEMPORARY files                /ogg/dirtmp: created
Credential store files         /ogg/dircrd: created
Masterkey wallet files         /ogg/dirwlt: created
Dump files                     /ogg/dirdmp: created

配置MGR
GGSCI (20_138-Mysql_Test1) 2> dit params mgr
PORT 7809

配置SOURCE端
GGSCI (20_138-Mysql_Test1) 4> dblogin sourcedb oggtest@localhost:3306,userid root,PASSWORD test123
Successfully logged INTO database.
GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 4> ADD EXTRACT e1,tranlog,BEGIN NOW
EXTRACT added.

GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 6> ADD exttrail /ogg/dirdat/e1,EXTRACT e1
EXTTRAIL added.

GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 7> edit params e1
EXTRACT e1
setenv (MYSQL_HOME="/var/lib/mysql")
tranlogoptions altlogdest /var/lib/mysql/mysql-bin.index
sourcedb oggtest@localhost:3306,userid root,PASSWORD test123
exttrail /ogg/dirdat/e1
dynamicresolution
gettruncates
TABLE oggtest.*;

GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 20> ADD EXTRACT p1,exttrailsource /ogg/dirdat/e1
EXTRACT added.

GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 21> ADD rmttrail /ogg/dirdat/r1,EXTRACT p1
RMTTRAIL added.

GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 22> edit param p1
EXTRACT p1
rmthost 192.168.20.139,mgrport 7809
rmttrail /ogg/dirdat/r1
passthru
gettruncates
TABLE oggtest.*;

配置TARGET端
GGSCI (20_139-Mysql_Test2) 3> dblogin sourcedb oggtest@localhost:3306,userid root,PASSWORD work123
Successfully logged INTO database.

GGSCI (20_139-Mysql_Test2 DBLOGIN AS root) 4> ADD checkpointtable oggtest.checkpoint
Successfully created checkpoint TABLE oggtest.checkpoint.

GGSCI (20_139-Mysql_Test2 DBLOGIN AS root) 5> ADD replicat r1,exttrail /ogg/dirdat/r1,checkpointtable oggtest.checkpoint
REPLICAT added.

GGSCI (20_139-Mysql_Test2 DBLOGIN AS root) 5> edit params r1
replicat r1
dboptions HOST localhost,connectionport 3306
targetdb oggtest,userid root,PASSWORD test123
assumetargetdefs
DISCARDFILE /ogg/dirrpt/r1.dsc,append,megabytes 50
MAP oggtest.*,target oggtest.*;

初始化数据
主库master-data方式导出oggtest库,该方式会记录导出时的log_file 信息
mysqldump -uroot -p --master-DATA oggtest > oggtest.sql

打开oggtest.sql 找到下面内容,记录下log_file和log_pos
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=5054;

修改extract e1 从导出的时的binlog开始抽取
GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 54> ALTER EXTRACT e1,VAM,lognum 3,logpos 5054
EXTRACT altered.

开启同步
开启抽取进程
GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 59> START e1
Sending START request TO MANAGER ...
EXTRACT E1 STARTING
开启投递进程
GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 59> START P1
Sending START request TO MANAGER ...
EXTRACT P1 STARTING

target端开启应用进程
GGSCI (20_139-Mysql_Test2 DBLOGIN AS root) 5> START  r1
Sending START request TO MANAGER ...
EXTRACT R1 STARTING

观察进程状态
SOURCE端
GGSCI (20_138-Mysql_Test1 DBLOGIN AS root) 63> info ALL
Program     STATUS      GROUP       Lag AT Chkpt  TIME Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     E1          00:00:00      00:00:03    
EXTRACT     RUNNING     P1          00:00:00      00:00:07    

TARGET端
GGSCI (20_139-Mysql_Test2 DBLOGIN AS root) 40> info ALL
Program     STATUS      GROUP       Lag AT Chkpt  TIME Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    RUNNING     R1          00:00:00      00:00:09    
主库插入数据,观察ogg日志信息,备库查看是否同步,查错拍错

“怎么搭建OGG 12c MySQL to MySQL”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联-成都网站建设公司网站,小编将为大家输出更多高质量的实用文章!


文章名称:怎么搭建OGG12cMySQLtoMySQL-创新互联
文章起源:http://myzitong.com/article/dseijg.html