dataX是阿里研发的主要做离线数据同步工具,支持多种数据库源同步。
文档:https://github.com/alibaba/DataX
下载:wget http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz
解压:tar -zxvf datax.tar.gz -C /usr/local/
自检:cd /usr/local/datax/bin/
python2.6 datax.py /usr/local/datax/job/job.json
授权:在源库和目标库的my.cnf中的[mysqld]中加入skip-grant-tables,否则终端显示没有权限执行失败
配置:vim /usr/local/datax/job/my_test.json,把下面那段复制进去
{ "job": { "setting": { "speed": { "channel":1 } }, "content": [ { "reader": { "name": "mysqlreader", "parameter": { "username": "root", "password": "123456", "column": [ "id", "name" ], "connection": [ { "table": [ "test" ], "jdbcUrl": [ "jdbc:mysql://192.168.112.129:3306/test" ] } ] } }, "writer": { "name": "mysqlwriter", "parameter": { "writeMode": "insert", "username": "root", "password": "123456", "column": [ "id", "name" ], "connection": [ { "jdbcUrl": "jdbc:mysql://192.168.112.130:3306/test", "table": [ "test" ] } ] } } } ] } }
执行:python2.6 /usr/local/datax/bin/datax.py /usr/local/datax/job/my_test.json
查看目标库192.168.112.130的test库test表是否和129的数据对应,一致说明执行成功。