环境准备
- List item
- Linux
- JDK(1.8以上,推荐1.8)
- Python(2或3都可以)
- Apache Maven 3.x (Compile DataX)
下载
wget https://datax-opensource.oss-cn-hangzhou.aliyuncs.com/202308/datax.tar.gz
建立datax 用户
useradd datax ; echo "datax" | passwd --stdin datax;
上传至linux 解压
tar -xzvf datax.tar.gz
测试是否可用
python /home/datax/datax/bin/datax.py /home/datax/datax/job/job.json
查看 Mysql 到Mysql 的模板
python /home/datax/datax/bin/datax.py -r mysqlreader -w mysqlwriter
返回
DataX (DATAX-OPENSOURCE-3.0), From Alibaba !
Copyright (C) 2010-2017, Alibaba Group. All Rights Reserved.
Please refer to the mysqlreader document:
https://github.com/alibaba/DataX/blob/master/mysqlreader/doc/mysqlreader.md
Please refer to the mysqlwriter document:
https://github.com/alibaba/DataX/blob/master/mysqlwriter/doc/mysqlwriter.md
Please save the following configuration as a json file and use
python {DATAX_HOME}/bin/datax.py {JSON_FILE_NAME}.json
to run the job.
{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"column": [],
"connection": [
{
"jdbcUrl": [],
"table": []
}
],
"password": "",
"username": "",
"where": ""
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"column": [],
"connection": [
{
"jdbcUrl": "",
"table": []
}
],
"password": "",
"preSql": [],
"session": [],
"username": "",
"writeMode": ""
}
}
}
],
"setting": {
"speed": {
"channel": ""
}
}
}
}
填写模板相印的信息
生成mysql2mysql.json文章来源地址https://www.toymoban.com/news/detail-685086.html
执行
python {DATAX_HOME}/bin/datax.py {JSON_FILE_NAME}.json
注意 datax 只支持一张表的同步 ,如果有多表同步需求, 可以配置多个json, 一个json对一张表
文章来源:https://www.toymoban.com/news/detail-685086.html
到了这里,关于datax 使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!