不同账号阿里云表格存储跨区域数据迁移

2020-03-16  本文已影响0人  henry技术探索记录员
1. 安装datax

下载编译好的datax,copy到一个ECS服务器实例上,解压即可:


image.png
2. 为每个表格table编写迁移脚本
{
    "job": {
        "setting": {
            "speed": {
                "channel": "5"
            }
        },
        "content": [{
            "reader": {
                "name": "otsreader",
                "parameter": {
                    "endpoint": "https://xxx.cn-shanghai.ots.aliyuncs.com",
                    "accessId": "xxx",
                    "accessKey": "xxx",
                    "instanceName": "xxx",
                    "table": "BALANCE_DETAIL",
                    "column": [{
                            "name": "partition_key"
                        },
                        {
                            "name": "primaryKey1"
                        },
                        {
                            "name": "primaryKey2"
                        },
                        {
                            "name": "primaryKey3"
                        },
                        {
                            "name": "col1"
                        },
                        {
                            "name": "col2"
                        },
                        {
                            "name": "col3"
                        }
                    ],
                    "range": {
                        "begin": [{
                            "type": "INF_MIN"
                        },{
                            "type": "INF_MIN"
                        },{
                            "type": "INF_MIN"
                        },{
                            "type": "INF_MIN"
                        }],
                        "end": [{
                            "type": "INF_MAX"
                        },{
                            "type": "INF_MAX"
                        },{
                            "type": "INF_MAX"
                        },{
                            "type": "INF_MAX"
                        }]
                    }
                }
            },
            "writer": {
                "name": "otswriter",
                "parameter": {
                    "endpoint": "http://yyy.cn-hongkong.vpc.ots.aliyuncs.com",
                    "accessId": "yyy",
                    "accessKey": "yyy",
                    "instanceName": "yyy",
                    "table": "yyy",
                    "primaryKey": [{
                        "name": "partition_key",
                        "type": "string"
                    },{
                        "name": "primaryKey1",
                        "type": "string"
                    },{
                        "name": "primaryKey2",
                        "type": "int"
                    },{
                        "name": "primaryKey3",
                        "type": "int"
                    }],
                    "column": [{
                            "name": "col1",
                            "type": "string"
                        },
                        {
                            "name": "col2",
                            "type": "string"
                        },
                        {
                            "name": "col3",
                            "type": "string"
                        }
                    ],
                    "writeMode": "PutRow"
                }
            }
        }]
    }
}
3. 将脚本拷贝到datax的job目录下:
image.png image.png image.png
4. 逐个执行脚本进行数据迁移
root$ python /usr/local/datax/bin/datax.py /usr/local/datax/job/dev/xxx.json

参考:
DataX迁移工具
DataX安装部署及小试

上一篇下一篇

猜你喜欢

热点阅读