本文主要是介绍DataX实现Gauss300->ADB PG(前一天数据)增量迁移,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、提前准备源Gauss300、目标 ADB PG数据库连接信息。
psql -hx.x.x.x -p25308 -Utest1 -ddb_name
xxxxxxpsql -hx.x.x.x -p3432 -Utest1 -ddb_name
xxxxxx
2、编写迁移脚本,并执行迁移。
#!/bin/bash
file_name=1.json
today_data=`date "+%Y-%m-%d 00:00:00"`
yesterday_data=`date -d "1 days ago" "+%Y-%m-%d 00:00:00"`
cat > $file_name << EOF
{"job": {"setting": {"speed": {"channel": 2},"errorLimit": {"record": 0,"percentage": 0.02}},"content": [{"reader": {"name": "gaussdbreader","parameter": {"username": "xxxxxx","password": "xxxxxx","column": ['*'],"connection": [{"querySql": ["select * from table_name where load_time >= '$yesterday_data' and load_time < '$today_data';"],"jdbcUrl": ["jdbc:opengauss://x.x.x.x/db_name"]}]}},"writer": {"name": "postgresqlwriter","parameter": {"username": "xxxxxx","password": "xxxxxx","column": ["*"],"connection": [{"jdbcUrl": "jdbc:postgresql://x.x.x.x:3432/db_name","table": ["table_name"]}]}}}]}
}
EOF
nohup python /data/datax/datax/bin/datax.py /data/shell/qianyi/$file_name > /data/shell/qianyi/$file_name.log 2>&1 &
这篇关于DataX实现Gauss300->ADB PG(前一天数据)增量迁移的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!