DataX实现Gauss300->ADB PG(前一天数据)增量迁移

1、提前准备源Gauss300、目标 ADB PG数据库连接信息。

psql -hx.x.x.x -p25308 -Utest1 -ddb_name
xxxxxx

psql -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 &