DataX使用

官方地址:https://github.com/alibaba/DataX
安装部署:https://blog.csdn.net/paicmis/article/details/53563824

  1. datax split目前仅支持单一主键,且主键类型是int或者varchar类型
  2. splitPk有值时,channel才会生效,否则都是单通道执行

 

{
    "job": {
        "content": [
            {
                "reader": {
                    "name": "mysqlreader", 
                    "parameter": {
                        "column": ["id","created_time","updated_time","tenant_id","payload"], 
                        "splitPk": "id",
                        "connection": [
                            {
                                "jdbcUrl": ["jdbc:mysql://11.11.86.22:3306/apollo_prod?autoReconnect=true"], 
                                "table": ["risk_data"]
                            }
                        ], 
                        "password": "******", 
                        "username": "****", 
                        "where": ""
                    }
                }, 
                "writer": {
                    "name": "postgresqlwriter", 
                    "parameter": {
                        "column": ["id","created_time","updated_time","tenant_id","payload"], 
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:postgresql://10.10.0.22:3433/appExtend", 
                                "table": ["risk_data"]
                            }
                        ], 
                        "password": "*******", 
                        "postSql": [], 
                        "preSql": ["delete from risk_data"], 
                        "username": "******"
                    }
                }
            }
        ], 
        "setting": {
            "speed": {
                "channel": 10
            }
        }
    }
}

//自定义sql
{
    "job": {
        "content": [
            {
                "reader": {
                    "name": "mysqlreader", 
                    "parameter": {
                        "connection": [
                            {
                                "querySql": ["select id,created_time,updated_time,tenant_id,payload from risk_data limit 1000;"],
                                "jdbcUrl": ["jdbc:mysql://11.1.1.22:3306/apollo_prod"]
                            }
                        ], 
                        "splitPk": "id",
                        "password": "*******", 
                        "username": "******"
                    }
                }, 
                "writer": {
                    "name": "postgresqlwriter", 
                    "parameter": {
                        "column": ["id","created_time","updated_time","tenant_id","payload"], 
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:postgresql://1.6.0.2:3433/appExtend", 
                                "table": ["risk_data"]
                            }
                        ], 
                        "password": "********", 
                        "postSql": [], 
                        "preSql": ["delete from risk_data"], 
                        "username": "********"
                    }
                }
            }
        ], 
        "setting": {
            "speed": {
                "channel": 10
            }
        }
    }
}

 

你可能感兴趣的:(DataX)