環境:
centos 7.4
mysql 5.5.58 glibc 64 位版,下載鏈接:https://dev.mysql.com/downloads/mysql/5.5.html#downloads
GoldenGate for mysql 12.3.0.1.0 linux 版本,下載鏈接:http://www.oracle.com/technetwork/middleware/goldengate/downloads/index.html

之前作者已經寫過一篇博客,專門介紹如何使用tar 包離線安裝mysql 服務,感興趣的讀者可以瀏覽查看mysql 5.5.58 tar包安裝部署,讀者們要特別留意my.cnf 的配置,因為GoldenGate 在對接mysql 時,需要依賴mysql 的binlog 日志。
安裝GoldenGate 前,建議大家先創建一個ogg 的系統用戶,方便管理
groupadd ogg useradd -s "/bin/bash" -m -d /home/ogg -b /home/ogg -g ogg ogg
切換到 ogg 系統用戶下,繼續以下操作
su - ogg
解壓已經下載好的GoldenGate 軟件
mkdir -p /home/ogg/ogg unzip 123011_ggs_Linux_x64_MySQL_64bit.zip -d /home/ogg/ogg/ cd ogg/ tar -xvf ggs_Linux_x64_MySQL_64bit.tar
進入ggsci 控制台
./ggsci
創建GoldenGate的子目錄,並且編輯mgr 配置文件
create subdirs
edit param mgr
mgr 服務的配置文件
port 9001 autostart er * autorestart er *
啟動mgr 服務
start mgr
編輯 ext_test 服務的配置文件
edit param ext_test
ext_test 服務的配置文件
EXTRACT ext_test SOURCEDB foo@localhost:3306, USERID root, PASSWORD mysql Setenv (NLS_LANG="AMERICAN_AMERICA.UTF8") Setenv (MYSQL_HOME="/opt/mysql-5.5.58-linux-glibc2.12-x86_64") TranLogOptions AltLogDest /opt/mysql-5.5.58-linux-glibc2.12-x86_64/binlog/replicalog.index GETTRUNCATES DISCARDROLLOVER ON FRIDAY DISCARDFILE ./dirrpt/ext_test.dsc , APPEND, MEGABYTES 1024 REPORTCOUNT EVERY 30 MINUTES, RATE EXTTRAIL ./dirdat/ex TABLE foo.test;
GoldenGate 對接mysql 和Oracle的配置文件有所不同,主要是連接 數據庫的設置不一樣,以及設置數據庫事務日志的方法也不同。
SOURCEDB 這個參數中,foo 代表是mysql 的database 名字,localhost 是指定mysql 的連接方式,3306 即是mysql 的端口號,后面接着的鑒權是mysql 數據庫中的用戶名和密碼,而非操作系統的用戶名和密碼。
TranLogOptions 參數則是指定mysql 事務日志的索引文件路徑
再次強調,讀者需要通過作者上一篇博客mysql 5.5.58 tar包安裝部署 的介紹,用戶應該如何設置mysql 的事務日志歸檔。
設置好ext_test配置后,就是對GoldenGate 增加這個服務。
add extract ext_test, TRANLOG, BEGIN NOW ADD EXTTRAIL ./dirdat/ex , EXTRACT ext_test, MEGABYTES 200
啟動ext_test 服務
start ext_test
查看GoldenGate 服務的運行狀態
info all
GoldenGate for mysq 另外一個和 對接Oracle 不同的地方,是GoldenGate 獲取mysql 表結構的方法。
在 ggsci 控制台上配置defgen 的配置文件
edit param defgen
defgen的配置文件內容
DEFSFILE dirdef/source.def, PURGE
SourceDB foo, UserID root, Password mysql
Table foo.test ;
在shell 窗口中執行以下命令,獲取mysql 需要同步的表的表結構
./defgen paramfile dirprm/defgen.prm
之前作者寫過一篇完整的GoldenGate的部署博客Oracle GoldenGate對接 Oracle 11g和Kafka,大家可以根據介紹將剩余的 dpe_test 和rep_test部分進行部署。
- 啟動ext_test 服務時報錯
如果用戶在啟動 ext_test服務時報錯信息如下,則證明是mysql 的binlog 日志ogg 沒有讀的權限,用戶應該修改mysql 的binlog 日志權限,允許其他的系統用戶讀取
2017-11-28 11:09:58 ERROR OGG-00146 Call to VAMInitialize returned with error status 600: VAM Client Report <CAUSE OF FAILURE : ERROR NO 13 - Confirm that the log file exists, that the path is correct, and that the correct permissions are set for Oracle GoldenGate. Also try specifying the path to the log index file by using the TRANLOGOPTIONS parameter with the ALTLOGDEST option. - /opt/mysql-5.5.58-linux-glibc2.12-x86_64/binlog/replicalog.index WHEN FAILED : While initializing binary log configuration WHERE FAILED : MySQLBinLog Reader Module CONTEXT OF FAILURE : No Information Available!>. 2017-11-28 11:09:58 ERROR OGG-01668 PROCESS ABENDING
修改mysql 的binlog 目錄的權限命令
chmod 765 /opt/mysql-5.5.58-linux-glibc2.12-x86_64/binlog/*
