安装源端ODBC:
yum install -y glibc glibc-devel glibc-headers glibc-common gcc
mysql odbc: tar -xzvf mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit.tar.gz cd mysql-connector-odbc-5.3.10-linux-glibc2.12-x86-64bit/lib cp libmyodbc5a.so /usr/lib64/libmyodbc5.so
unix odbc: tar -xzvf unixODBC-2.3.4.tar.gz
cd unixodbc-2.3.2 export CC=gcc
当服务器系统为 UNIX/LINUX 64bits 时,在./configure 之前需执行 export CFLAGS="-maix64 -DBUILD_REAL_64_BIT_MODE" export OBJECT_MODE=64
./configure --enable-drivers=no --with-iconv-char-enc=GB18030 --enable-gui=no --enable-iconv=yes make make install
cd /usr/local/etc/ odbc.ini 参数内容如下所示:
[mysql] Driver=MySQL ODBC 5.1 Driver DATABASE=mysql
odbcinst.ini 参数内容如下所示:
DESCRIPTION=MYSQL ODBC 5.1 DRIVER SERVER=127.0.0.1 UID=dmhs PASSWORD=dmhs
[MySQL ODBC 5.1 Driver] Driver=/usr/lib64/libmyodbc5.so UsageCount=1
测试: isql -v mysql dmhs dmhs
?
安装dmhs:
./dmhs_V4.1.2_pack2_dm7_rev100195_rh6_64_veri_20210618.bin
?
?
?
?
?
?
?
?
?
?
?
?
mysql 开启源端数据库的 binlog 及 binlog format
开启 mysql 的 binlog,修改 binlog format。 [mysqld] log-bin=mysql-bin 或者 “binlog日志路径” binlog_format=row
当包含 lob 数据的同步是,针对 lob 数据的大小,还需设置 max_allowed_packet,如下所示: max_allowed_packet=100M
查看: show variables like 'log_bin'; show variables like 'binlog_format';
配置参数文件(bin/dmhs.hs):
vi dmhs.hs
<?xml version="1.0" encoding="GB2312"?>
<dmhs> <base> <siteid>1</siteid> <mgr_port>5345</mgr_port> <chk_interval>3</chk_interval> <ckpt_interval>60</ckpt_interval> <lang>ch</lang> <version>2.0</version> </base>
<cpt> <db_type>mysql</db_type> <db_server>127.0.0.1</db_server> <db_port>3306</db_port> <db_name>testdb</db_name> <db_user>root</db_user> <db_pwd>root</db_pwd> <ddl_mask>op:obj</ddl_mask> <arch> <clear_interval>600</clear_interval> <clear_flag>0</clear_flag> <dir>/mysql/log/3306</dir> </arch> <send> #目标端 <ip>127.0.0.1</ip> <mgr_port>6345</mgr_port> <data_port>6346</data_port> <filter> <enable> <item>TESTDB.*</item> </enable> </filter> </send> </cpt> </dmhs>
当 mysql 服务器版本低于 5.6 时,必须设置<arch><dir>,否则同步可以出现 错误, mysql 服务器版本为 5.6 及以上时,可不设置改参数
重启进程:
/etc/init.d/DmhsServiceHSSERVER restart cp /etc/init.d/DmhsServiceHSSERVER ~/dmhs/bin/dmhs_serverd ?
修改目的端配置文件(bin/dmhs.hs)
<?xml version="1.0" encoding="GB2312"?>
<dmhs> <base> <lang>ch</lang> <mgr_port>5345</mgr_port> <chk_interval>2</chk_interval> <ckpt_interval>60</ckpt_interval> <siteid>11</siteid> <version>2.0</version> </base>
<exec> <recv> <data_port>5346</data_port> </recv> <db_type>DM7</db_type> <db_server>127.0.0.1</db_server> <db_user>SYSDBA</db_user> <db_pwd>SYSDBA</db_pwd> <db_port>5236</db_port> <level>0</level> <exec_mode>1</exec_mode> <exec_thr>16</exec_thr> <exec_sql>1024</exec_sql> <exec_trx>5000</exec_trx> <exec_rows>1000</exec_rows> <case_sensitive>1</case_sensitive> #1为区分大小写,0为不区分 <exec_policy>0</exec_policy> <toggle_case>0</toggle_case> <commit_policy>1</commit_policy> <enable_merge>1</enable_merge> <check_key>0</check_key> </exec> </dmhs>
重启服务: /etc/init.d/DmhsServiceHSSERVER restart cp /etc/init.d/DmhsServiceHSSERVER ~/dmhs/bin/dmhs_serverd
目的端启动执行服务
[root@mysql-temp bin]# ./dmhs_console set lang ch Connect Start exec
注意,如果start exec模块加载失败,bin/log/报错2021-09-26 15:38:55 MGR[ERROR]: 库文件 libdmhs_exec.so 未找到, 出错: 0 处理方法: ldd ./libdmhs_exec.so libdmoci.so => not found
cp /home/dmdba/dm/dmhs/bin/stat/libdmoci.so /home/dmdba/dm/dmdbms/bin/ 恢复正常;
?
源端数据装载:
./dmhs_console set lang ch Connect copy 0 "sch.name='TESTDB'" DICT|LSN|CREATE|INSERT|INDEX --装载数据 copy 0 "sch.name='TESTDB' and tab.name='xxx' " DICT|LSN|INSERT|INDEX --装载数据
bin/log/hs..log 报错libcpt_mysql.so缺失: ldd ./libcpt_mysql.so 发现: libdmhs_net.so => not found libdmhs_pub.so => not found ?
?
copy 0 "sch.name='PERSON_2'" DICT|LSN|CREATE|INSERT|INDEX --装载数据
查看目的端/opt/dmhs/bin/log/目录下的dmhs日志是否完成装载 查看目的端~/dmhs/bin/log/目录下的dmhs日志是否完成装载
?确认没有错误后,启动源端cpt
./dmhs_console set lang ch Connect Start cpt 或 start
查看状态: state cpt 0
目标端查看状态: ./dmhs_console set lang ch Connect state
?DMHS> state MGR: Execute TYPE VID SITEID EXEC/CPT IP PORT DBNAME ------- --- ------ ----------- ---- ------ Execute 0 1 172.16.30.1 5345
exec 1
?
社区地址:https://eco.dameng.com
|