1.安装python3
链接:https://pan.baidu.com/s/1YthL24An_972MRAEPewH9A
提取码:hxan
安装过程自行百度
2.安装datax
链接:https://pan.baidu.com/s/1Hg6YiEpWaba7u7zJlbdymA
提取码:j9s4
解压即可
3.建立文件,比如:transform.json,内容如下:
{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"column": [
"*"
],
"connection": [
{
"jdbcUrl": [
"jdbc:mysql://localhost:3306/源数据库名?useUnicode=true&characterEncoding=gbk&useSSL=false"
],
"table": [{
"表名"
}
]
}
],
"password": "密码",
"username": "用户名",
"where": "1=1"
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"column": [
"*"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://ip:3306/目标数据库名?useUnicode=true&characterEncoding=gbk&useSSL=false",
"table": [{
"表名"
}
]
}
],
"password": "密码",
"username": "用户名",
"preSql": [],
"session": [],
"preSql": [
"truncate table 表名"
],
"writeMode": "insert"
}
}
}
],
"setting": {
"speed": {
"channel": "2"
},
"errorLimit": {
"record": 0
}
}
}
}
"column": ["*"],表示所有列,目前暂时成功单表同步。
4.执行命令 python datax.py transform.json

图片.png
如果哪位大佬有更好的同步方式,还请不吝赐教,万分感谢!!!