需求:把a服务器上mysql数据迁移到b服务器上mysql中。
1、下载datax: https://github.com/alibaba/DataX
2.解压tar -zxvf datax.tar.gz
3.编辑作业文件 diag.json
{ "job": { "content": [ { "reader": { "name": "mysqlreader", "parameter": { "username": "root", "password": "langt3333", "column": ["*"], "splitPk": "id", "connection": [ { "table": [ "diag_8" ], "jdbcUrl": [ "jdbc:mysql://192.168.2.1***:3306/diagbot?useUnicode=true&characterEncoding=utf8" ] } ] } }, "writer": { "name": "mysqlwriter", "parameter": { "writeMode": "insert", "username": "root", "password": "diagbo333", "column": [ "*" ], "session": [ "set session sql_mode='ANSI'" ], "preSql": [ "truncate diag_8" ], "connection": [ { "jdbcUrl": "jdbc:mysql://192.168.2.**:3306/diagbot11?useUnicode=true&characterEncoding=utf8", "table": [ "diag_8" ] } ] } } } ], "setting": { "speed": { "channel": 5 } } } }
4、运行作业文件:
python datax.py ../job/diag.json