DataX 离线跨网场景的实施配置

配置仅限于跨不同网情况,网络互通情况方案和配置会更简单一点

内网A:MySql数据转换成Csv

{
  "job": {
      "setting": {
          "speed": {
               "channel":1
          }
      },
      "content": [
          {
              "reader": {
                  "name": "mysqlreader",
                  "parameter": {
                      "username": "root",
                      "password": "",
                      "connection": [
                          {
                              "querySql": [
                                  "select id,name from table;"
                              ],
                              "jdbcUrl": [
                                  "jdbc:mysql://127.0.0.1/database"
                              ]
                          }
                      ]
                  }
              },
              "writer": {
                  "name": "txtfilewriter",
                  "parameter": {
                      "print": true,
                      "encoding": "UTF-8",
                      "path": "/result",
                      "fileName": "result.csv",
                      "writeMode": "truncate",
                      "dateFormat": "YYYY-MM-dd hh:mm:ss",
                      "header":["id", "name"]
                  }
              }
          }
      ]
  }
}

  

内网B:CSV导入到内网B配置:

{
    "job": {
        "setting": {
            "speed": {
                "channel": 2
            }
        },
        "content": [
            {
                 "reader": {
                    "name": "txtfilereader",
                    "parameter": {
                        "path":["D:/result/result.csv"],
                        "encoding": "UTF-8",
                        "column": [
                            {
                                "index": 0,
                                "name":"id",
                                "type": "long"
                            },
                            {
                                "index": 1,
                                "name":"name",
                                "type": "string"
                            }
                        ],
                        "skipHeader": "true"
                    }
                },
                "writer": {
                    "name": "mysqlwriter",
                    "parameter": {
                        "writeMode": "insert",
                        "username": "root",
                        "password": "",
                        "column": [
                            "id", "name"
                        ],
                        "preSql": [
                            "truncate table table;"
                        ],
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/table?characterEncoding=utf-8",
                                "table": [
                                    "table"
                                ]
                            }
                        ]
                    }
                }
            }
        ]
    }
}

  

 注意编码和字段支持的类型,详细可查看DataX官方文档。

posted @ 2020-03-10 18:28  leeolevis  阅读(610)  评论(0编辑  收藏  举报