DataX 安装和使用

时间:2020-12-28 06:02:33

阿里云介绍

1. 下载安装包。作为阿里主要的数据传输工具Datax,阿里已经完全开源到github上面了。下载地址(https://github.com/alibaba/DataX)。

2. 安装环境:

  • JDK(1.6以上,推荐1.6)
  • Python(推荐Python2.6.X)
  • Apache Maven 3.x (Compile DataX)

3. 解压到工作目录。/usr/local/datax

4. 编写源和目标表的json文件

{
"job": {
"setting": {
"speed": {
"channel":
},
"errorLimit": {
"record": ,
"percentage": 0.02
}
},
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"writeMode": "insert",
"username": "root",
"password": "******",
"column": [
"rec_id",
"column",
"etl_time"
],
"connection": [
{
"table": [
"source_table"
],
"jdbcUrl": [
"jdbc:mysql://11.278.80.200:34001/DW"
] }
]
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"username": "root",
"password": "*****",
"column": [
"rec_id",
"column",
"etl_time"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://10.208.83.202:30001/DW",
"table": [
"target_table"
]
}
],
}
}
}
],
"setting": {
"speed": {
"channel":
},
"errorLimit": {
"record":
}
}
}
}

5. 运行脚本

python /home/admin/datax3/bin/datax.py ./json/table_1.json