DataX

1.簡介

DataX 是阿里云DataWorks數據集成的開源版本,在阿里巴巴集團內被廣泛使用的離線數據同步工具/平臺。DataX 實現了包括 MySQL、Oracle、OceanBase、SqlServer、Postgre、HDFS、Hive、ADS、HBase、TableStore(OTS)、MaxCompute(ODPS)、Hologres、DRDS, databend 等各種異構數據源之間高效的數據同步功能。

2.工具安裝部署

2.1.安裝 jdk1.8

請參考相關 JDK 1.8 的安裝配置教程,此處略。

2.2. 安裝 python 2.x

請參考相關 Python 2.x 安裝配置教程,此處略。

2.3.安裝 DataX

步驟1:下載DataX

下載地址:http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz

步驟2:解壓安裝包到/opt/module下

tar -zxvf datax.tar.gz -C /opt/module/

image

步驟3:增加HighGo數據庫reader和writer支持

下載插件解壓至plugin下。

下載鏈接:https://pan.baidu.com/s/1Cqw3Zn9Q_dlsgQZbNcQedQ?pwd=bmde

3.DataX 配置

3.1.編寫同步任務 job 配置文件

?下面配置將 mysql 中 mydb 庫下的 tb_datax 表的數據同步到 HighGo 數據庫 tb_datax 表里,其中 channel 是并發(fā)數量。

/opt/module/datax/job/mysql2highgo.json

{
"job": {
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"column": ["datax_id","datax_name","datax_code"],
"connection": [
{
"jdbcUrl": ["jdbc:mysql://192.168.100.21:3306/mydb?useSSL=false"],
"table": ["tb_datax"]
}
],
"password": "Mysql@123",
"username": "root",
"where": ""
}
},
"writer": {
"name": "highgowriter",
"parameter": {
"column": ["datax_id","datax_name","datax_code"],
"writeMode": "upsert(datax_id)"
"connection": [
{
"jdbcUrl": "jdbc:highgo://192.168.100.101:5866/highgo?currentSchema=datax",
"table": ["tb_datax"]
}
],
"password": "Qwer@1234",
"postSql": [],
"preSql": [],
"username": "sysdba"
}
}
}
],
"setting": {
"speed": {
"channel": "3"
}
}
}
}

3.2.執(zhí)行 datax.py

python /opt/module/datax/bin/datax.py /opt/module/datax/job/mysql2highgo.json

3.3.查看執(zhí)行結果

image