1、安装datax
安装参考[linux安装dataX-CSDN博客](https://blog.csdn.net/hzp666/article/details/127350768)
2、配置datax同步mysql
配置mysql隔离级别,进入mysql终端
SET GLOBAL transaction_isolation='READ-COMMITTED';
配置数据源
jdbc:mysql://16gmaster:33060/studio?useUnicode=true&characterEncoding=utf8&useLocalSessionState=true
配置执行器
配置任务模版
配置单任务
按步骤选择数据抽取库,数据合并库,映射字段,构建datax的可执行json文件,选择任务模版,点击下一步任务就创建完成了,可以在任务详情里查看
最后可以运行的json文件
{
"job": {
"setting": {
"speed": {
"channel": 1,
"bytes": 0
},
"errorLimit": {
"record": 100
},
"restore": {
"maxRowNumForCheckpoint": 0,
"isRestore": false,
"restoreColumnName": "",
"restoreColumnIndex": 0
},
"log": {
"isLogger": false,
"level": "debug",
"path": "",
"pattern": ""
}
},
"content": [{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "root",
"password": "123456",
"column": [
"menu_id",
"pid",
"sub_count",
"type",
"title",
"name",
"component",
"menu_sort",
"icon",
"path",
"i_frame",
"cache",
"hidden",
"permission",
"create_by",
"update_by",
"create_time",
"update_time"
],
"splitPk": "",
"connection": [{
"table": [
"sys_menu_source"
],
"jdbcUrl": [
"jdbc:mysql://16gmaster:33060/studio?useUnicode=true&characterEncoding=utf8&useLocalSessionState=true"
]
}]
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"username": "root",
"password": "123456",
"writeMode": "insert",
"column": [
"menu_id",
"pid",
"sub_count",
"type",
"title",
"name",
"component",
"menu_sort",
"icon",
"path",
"i_frame",
"cache",
"hidden",
"permission",
"create_by",
"update_by",
"create_time",
"update_time"
],
"connection": [{
"table": [
"sys_menu_target"
],
"jdbcUrl": "jdbc:mysql://16gmaster:33060/studio?useUnicode=true&characterEncoding=utf8&useLocalSessionState=true"
}]
}
}
}]
}
}