DataX是一款快速可靠的數(shù)據(jù)同步工具,支持從不同的數(shù)據(jù)源中讀取數(shù)據(jù)并將其寫入到目標(biāo)數(shù)據(jù)源中。其中,DataX JSON腳本支持對數(shù)據(jù)源、目標(biāo)源、插件以及同步任務(wù)進(jìn)行配置,下面我們來具體了解一下DataX JSON腳本的編寫。
配置數(shù)據(jù)源的JSON腳本
{ "type": "mysql", "username": "root", "password": "123456", "column": [ "id", "name", "age" ], "connection": [ { "jdbcUrl": [ "jdbc:mysql://ip:port/database" ], "table": [ "user" ] } ] }
配置目標(biāo)源的JSON腳本
{ "type": "elasticsearch", "host": [ "ip:port" ], "index": "user", "mapping": "", "settings": "" }
配置插件的JSON腳本
{ "name": "stream", "parameter": { "encoding": "UTF-8" } }
配置同步任務(wù)的JSON腳本
{ "job": { "content": [ { "reader": { "name": "mysqlreader", "parameter": { "connection": [ { "jdbcUrl": "jdbc:mysql://ip:port/database", "querySql": "select id, name, age from user" } ], "column": [ "id", "name", "age" ], "splitPk": "", "splitMode": "" } }, "writer": { "name": "elasticsearchwriter", "parameter": { "clustername": "elasticsearch", "host": "ip:port", "index": "user", "batchsize": 1000, "mapping": "", "settings": "" } } } ], "setting": { "speed": { "channel": 3 } } } }