dataxを使ってmysql間でデータを同期する

3823 ワード

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"
 }
    }
  }
}