以前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 nowADD EXTTRAIL /opt/OGG/dirdat/extract/AL, EXTRACT ext-alledit params ext-all extract ext-allSETENV (NLS_LANG =AMERICAN_AMERICA.ZHS16GBK)userid is1ogg,password passw0rdexttrail /opt/OGG/dirdat/extract/ALdiscardfile /opt/OGG/discard/ext-all.txt, append, megabytes 100 DDL INCLUDE MAPPED OPTYPE alter OBJNAME ECP.TAB*TABLE ecp.*; add EXTRACT p-air, EXTTRAILSOURCE /opt/OGG/dirdat/extract/AL, BEGIN nowadd rmttrail /opt/OGG/dirdat/rl extract p-airedit params p-air extract p-airSETENV (NLS_LANG =AMERICAN_AMERICA.ZHS16GBK)userid is1ogg,password passw0rdRMTHOST 192.168.1.4,MGRPORT 7809,TCPBUFSIZE 100000,TCPFLUSHBYTES 300000rmttrail /opt/OGG/dirdat/rldiscardfile /opt/OGG/discard/p-air.txt, append, megabytes 100 TABLE ecp.*;
target端:
add replicat repl, exttrail /opt/OGG/dirdat/rl,nodbcheckpointedit params repl replicat replDBOPTIONS HOST 127.0.0.1, CONNECTIONPORT 3306TARGETDB ecp,userid root,password xifenfeiassumetargetdefsreperror default,discarddiscardfile /tmp/mysql.dsc,append,megabytes 100MAP ECP.TAB_UUM_DEPT, TARGET ecp.tab_uum_dept;MAP ECP.TAB_UUM_DEPT_LEADER, TARGET ecp.tab_uum_dept_leader;
--转自