使用datax在mysql之间同步数据

使用datax在mysql之间同步数据

 

详细参考

github:https://github.com/alibaba/DataX/wiki/Quick-Start

 

1. 下载datax

wget http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz

 

2. 解压、修改目录权限

tar zxvf datax.tar.gz
sudo chmod -R 755 datax

 

3. 执行同步job

python datax.py ../job/job.json

 

4. job格式

{
  "job": {
    "content": [
      {
        "reader": {
          "name": "mysqlreader",
          "parameter": {
            "column": ["id_", "topic_id_", "speak_id_", "file_id_"],
            "connection": [
              {
                "jdbcUrl": ["jdbc:mysql://*.*.*.*:3306/a?useUnicode=true&characterEncoding=UTF-8"],
                "table": ["a"]
              }
            ],
            "password": "*****",
            "username": "a",
            "where": "",
            "session": ["set names utf8mb4"]
          }
        },
        "writer": {
          "name": "mysqlwriter",
          "parameter": {
            "column": ["id_", "topic_id_", "speak_id_", "file_id_"],
            "connection": [
              {
                "jdbcUrl": "jdbc:mysql://*.*.*.*:3306/b?useUnicode=true&characterEncoding=UTF-8",
                "table": ["b"]
              }
            ],
            "password": "****",
            "username": "b",
            "where": "",
            "session": ["set names utf8mb4"]
          }
        }
      }
    ],
    "setting": {
      "speed": {
        "channel": "5"
 }
    }
  }
}

你可能感兴趣的:(数据库)