DataX 安装和使用

阿里云介绍

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": 3
            },
            "errorLimit": {
                "record": 0,
                "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": 1
            },
            "errorLimit": {         
                "record": 10
            }
        }
    }
}

5. 运行脚本

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

 

posted @ 2018-11-19 14:57  Jesse_Li  阅读(402)  评论(0编辑  收藏  举报