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"
}
}
}]
}
}
- endpoint为表格存储实例的访问url;
- accessId和accessKey到阿里云网站账号的
AccessKey管理
中查找到; - instanceName为表格存储实例名
- table为表格名
3. 将脚本拷贝到datax的job目录下:
image.png image.png image.png4. 逐个执行脚本进行数据迁移
root$ python /usr/local/datax/bin/datax.py /usr/local/datax/job/dev/xxx.json
网友评论