DataX同步數據步驟很簡單,其他不少人,寫的華麗呼哨,自己總結一篇。試了window 估計linux 一樣,步驟如下
1.下載 DataX 解壓,配置json,使用命令行同步
安裝DataX要求
python 2或者3
JDK
下載地址
鏈接: http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz
失效直接在github搜索 DataX 下載就行了
自己整理的文檔,失效 滴滴我 下載地址:
鏈接: datax python3用法和使用總結
解壓出來是這樣
然後打開 打開 datax/bin文件夾,再這個目錄下面cmd執行腳本命令
python datax.py test.json
中文亂碼 處理 回車就不是中文亂碼了。
然後就能同步完成了
說明:
datax.py 啓動的腳本
test.json 爲配置文件
json說明.txt 是配置文件的說明文件
python2 版本 是安裝了python2的就用python2裏面的py文件拖出來執行
python3 版本 是安裝了python3的就用python3裏面的py文件拖出來執行
test.json 爲配置文件
{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": ["jdbc:mysql://localhost:3306/light_attenuation?serverTimezone=UTC&characterEncoding=utf-8"],
"table": ["query_device"]
}
],
"password": "root",
"username": "root",
}
},
"writer": {
"name": "mysqlwriter",
"writeMode": "replace",
"parameter": {
"column": ["*"],
"preSql": [
"delete from query_device"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://10.180.5.15:3306/light_attenuation?serverTimezone=UTC&characterEncoding=utf-8",
"table": ["query_device"]
}
],
"password": "root",
"username": "root",
}
}
}
],
"setting": {
"speed": {
"channel": "5"
}
}
}
}
json說明.txt 是配置文件的說明文件
{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": ["jdbc:mysql://localhost:3306/light_attenuation?serverTimezone=UTC&characterEncoding=utf-8"],
"table": ["query_device"]
}
],
"password": "root",
"username": "root",
}
},
"writer": {
"name": "mysqlwriter", // mysql寫入對應的驅動名稱
"writeMode": "insert", //insert/replace/update
"parameter": {
"column": ["*"],
"preSql": [
"delete from query_device" // 刪除再同步
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://10.180.5.15:3306/light_attenuation?serverTimezone=UTC&characterEncoding=utf-8",
"table": ["query_device"]
}
],
"password": "root",
"username": "root",
}
}
}
],
"setting": {
"speed": {
"channel": "5"
}
}
}
}