##下载datax
cd?/home/yym/
wget http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz
##解压
tar -zxvf datax.tar.gz
##配置环境变量
vim ~/.bashrc ##用户环境变量
export PATH=/home/yym/datax/openlogic-openjdk-11.0.21+9-linux-x64/bin:$PATH
source ~/.bashrc
##删除plugin
/home/yym/datax/datax/
rm -rf ./plugin/*/._*
##执行datax看下环境是否正常
cd /home/yym/datax/datax/bin
python3 datax.py ../job/job.json
##python与python3语法不一样,需要修改datax.py文件
python3执行报print错误,修改如下
举例
print >> sys.stderr, "DataX Process was killed ! you did ?"
改为
print ( sys.stderr, "DataX Process was killed ! you did ?")
##yym_data.json
{
"job": {
"content": [
{
"reader": {
"name": "oraclereader",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": ["jdbc:oracle:thin:@192.168.3.156:1522:lhrcdb1"],
"table": ["hp_assets_user_visit_count_d"]
}
],
"password": "123456",
"username": "c##yym_admin"
}
},
"writer": {
"name": "postgresqlwriter",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": "jdbc:postgresql://192.168.3.156:17700/test",
"table": ["yym_admin.hp_assets_user_visit_count_d"]
}
],
"password": "123456",
"postSql": [],
"preSql": [],
"username": "yym_admin"
}
}
},
{
"reader": {
"name": "oraclereader",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": ["jdbc:oracle:thin:@192.168.3.156:1522:lhrcdb1"],
"table": ["hp_assets_user_visit_detail"]
}
],
"password": "123456",
"username": "c##yym_admin"
}
},
"writer": {
"name": "postgresqlwriter",
"parameter": {
"column": ["*"],
"connection": [
{
"jdbcUrl": "jdbc:postgresql://192.168.3.156:17700/test",
"table": ["yym_admin.hp_assets_user_visit_detail"]
}
],
"password": "123456",
"postSql": [],
"preSql": [],
"username": "yym_admin"
}
}
}
],
"setting": {
"speed": {
"channel": "2"
}
}
}
}
##oracle表数据全量同步到postgresql
python3 /home/yym/datax/datax/bin/datax.py -r oraclereader -w postgresqlwriter