以前oracle to mysql實驗總是有亂碼問題不能解決,後來和同事交流中,他說oracle使用ogg的11g版本,mysql使用ogg的10g版本可以解決亂碼問題,開始我還是懷疑,因為想新的版本都不行,難道老版本就可以解決這個問題嗎?抱著試試看的態度,做了個實驗,盡然成功了,把實驗的相關情況記錄下來
mysql參數配置(cat /etc/my.cnf):
[client]
default-character-set = gbk
[mysqld]
lower_case_table_names=1–表名不區分大小寫(省的在repl進程中因為大小寫問題導致不能捕獲資料)
character-set-server = gbk
表/列編碼:均為gbk
Note:
1、因為mysql是target端,所以對於log-bin/binlog_format參數無要求
2、通過以上設定確保mysql的所有相關編碼均為gbk
系統編碼配置(cat /etc/sysconfig/i18n):
source:
LANG=”zh_CN.GBK”
SUPPORTED=”zh_CN.GBK:zh_CN:zh”
SYSFONT=”latarcyrheb-sun16″
target:
LANG=”zh_CN.GBK”
SYSFONT=”latarcyrheb-sun16″
Note:是的系統編碼和mysql編碼相同
OGG配置過程:
source端:
add extract ext-all,tranlog,begin now
ADD EXTTRAIL /opt/OGG/dirdat/extract/AL, EXTRACT ext-all
edit params ext-all
extract ext-all
SETENV (NLS_LANG =AMERICAN_AMERICA.ZHS16GBK)
userid is1ogg,password passw0rd
exttrail /opt/OGG/dirdat/extract/AL
discardfile /opt/OGG/discard/ext-all.txt, append, megabytes 100
DDL INCLUDE MAPPED OPTYPE alter OBJNAME ECP.TAB*
查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/
TABLE ecp.*;
add EXTRACT p-air, EXTTRAILSOURCE /opt/OGG/dirdat/extract/AL, BEGIN now
add rmttrail /opt/OGG/dirdat/rl extract p-air
edit params p-air
extract p-air
SETENV (NLS_LANG =AMERICAN_AMERICA.ZHS16GBK)
userid is1ogg,password passw0rd
RMTHOST 192.168.1.4,MGRPORT 7809,TCPBUFSIZE 100000,TCPFLUSHBYTES 300000
rmttrail /opt/OGG/dirdat/rl
discardfile /opt/OGG/discard/p-air.txt, append, megabytes 100
TABLE ecp.*;
target端:
add replicat repl, exttrail /opt/OGG/dirdat/rl,nodbcheckpoint
edit params repl
replicat repl
DBOPTIONS HOST 127.0.0.1, CONNECTIONPORT 3306
TARGETDB ecp,userid root,password xifenfei
assumetargetdefs
reperror default,discard
discardfile /tmp/mysql.dsc,append,megabytes 100
MAP ECP.TAB_UUM_DEPT, TARGET ecp.tab_uum_dept;
MAP ECP.TAB_UUM_DEPT_LEADER, TARGET ecp.tab_uum_dept_leader;