接口说明
配置传输任务,内容包括传输对象的映射关系,数据库连接信息等。
请求结构
POST /v{version}/task/{dtsId}/config
Host: dts.baidubce.com
Authorization: authorization string
{
"type": "migration",
"granularity" : "instance",
"schemaMapping" : [ {
"dst" : "test.table_dst",
"src" : "test.table_src",
"where" : "where",
"type" : "table"
} ],
"dataType" : [ "base" ],
"srcConnection" : {
"dbPass" : "dbPass",
"dbPort" : 3306,
"instanceId" : "rdsmfgdti3d53f5",
"instanceType" : "bcerds",
"dbUser" : "_dts_trans_",
"field_whitelist" : "field_whitelist",
"dbType" : "mysql",
"dbHost" : "192.168.1.1",
"field_blacklist" : "field_blacklist",
"region" : "bj"
}
}
请求体参数
参数名称 |
参数类型 |
是否必选 |
描述 |
示例值 |
参数位置 |
version |
String |
是 |
API版本号 |
"1" |
URL参数 |
dtsId |
String |
是 |
任务ID |
"dtsmxxxyyy" |
URL参数 |
type |
String |
是 |
任务类型(数据传输任务:migration),目前仅支持数据传输任务 |
migration |
Request Body 参数 |
dataType |
String[] |
是 |
传输数据类型数组(schema:结构迁移;base:全量迁移;increment:增量迁移) |
["base"] |
Request Body 参数 |
srcConnection |
Connection |
是 |
源端 |
srcConnection |
Request Body 参数 |
dstConnection |
Connection |
是 |
目标端 |
dstConnection |
Request Body 参数 |
granularity |
String |
是 |
传输任务的粒度(instance:实例级;dbtb:库表级) |
instance |
Request Body 参数 |
schemaMapping |
Schema[] |
是 |
schema |
schema |
Request Body 参数 |
accountMapping |
AccountMapping[] |
否 |
账号迁移 |
accountMapping |
Request Body 参数 |
incrIgnoreType |
String |
否 |
特殊DDL过滤 |
drop,truncate |
Request Body 参数 |
initPosition |
InitPosition |
否 |
自定义同步点 |
initPosition |
Request Body 参数 |
Connection字段数据结构说明
参数名称 |
参数类型 |
是否必选 |
描述 |
示例值 |
instanceType |
String |
否 |
实例类型 |
bcerds |
region |
String |
否 |
地域 |
bj |
dbType |
String |
否 |
数据库类型 |
mysql |
dbUser |
String |
否 |
数据库访问账号 |
dts_trans |
dbPass |
String |
否 |
数据库访问密码 |
|
dbPort |
Integer |
否 |
数据库访问端口 |
3306 |
dbHost |
String |
否 |
数据库IP或主机名 |
192.168.1.1 |
instanceId |
String |
否 |
实例ID |
rdsmfgdti3d53f5 |
dbServer |
String |
否 |
数据库IP或主机名。支持IP:端口,IP或域名与端口以英文冒号分隔,多个地址以英文逗号分隔 |
192.168.1.1:3306 |
shardUrl |
String |
否 |
分片IP或主机名。支持IP:端口,IP或域名与端口以英文冒号分隔,多个地址以英文逗号分隔 |
192.168.1.1:3306,192.168.1.1:3306 |
announceServer |
String |
否 |
redis cluster announce IP/Port。若redis cluster低于4.0或未设置announce IP/Port该字段填空即可。长度限制10240 |
192.168.1.1:3306,192.168.1.1:3306(与dbServer一一对应) |
field_whitelist |
String |
否 |
列过滤(白名单) |
field_whitelist |
field_blacklist |
String |
否 |
列过滤(黑名单) |
field_blacklist |
srcDstFlag |
String |
否 |
公有云上redis实例:必选。标识公有云上实例源端和目标端。源端取值"src",目标端取值"dst"。非公有云,非redis实例:可为空。) |
src |
supportOnlineDDL |
String |
否 |
同步Online DDL |
true,false |
maxRetryTime |
String |
否 |
重试时间 |
720 |
sqlType |
String |
否 |
同步语句选择 |
I,U,D,Q |
positionStrategy |
String |
否 |
可选值:fail(如果给定offset不存在,这任务报错退出) base(如果给定offset不存在,则任务从全量开始重新同步) |
fail |
zone |
String |
否 |
接入类型为bcegateway时,需要指定可用区 |
cn-bd-a |
vpcShortId |
String |
否 |
接入类型为bcegateway时,需要指定VPC短ID |
vpc-46k27rb9wppz |
subnetShortId |
String |
否 |
接入类型为bcegateway时,需要指定子网短ID |
sbn-qtm3d4eituqc |
Schema字段数据结构说明
参数名称 |
参数类型 |
是否必选 |
描述 |
示例值 |
type |
String |
否 |
需要传输的对象类型,取值有:db(库),table(表), view(视图),function(函数), procedure(存储过程) |
table |
src |
String |
否 |
源库的schema名称 |
test.table_src |
dst |
String |
否 |
目标库的schema名称 |
test.table_dst |
where |
String |
否 |
where过滤条件 |
where |
AccountMapping字段数据结构说明
参数名称 |
参数类型 |
是否必选 |
描述 |
示例值 |
user |
String |
否 |
用户 |
dts_user |
hosts |
String[] |
否 |
地址 |
["%", "1.2.3.4", "10.10.10.1"] |
InitPosition字段数据结构说明
参数名称 |
参数类型 |
是否必须选 |
描述 |
示例值 |
type |
String |
否 |
默认值offset |
offset |
position |
String |
否 |
填写redis实例replication backlog中有效有效的offset值,格式为:"9654766427"。若不填写则标识做全量+增量迁移 |
9654766427 |
响应头参数
除公共头域,无其它特殊头域。
响应体参数
响应体字段数据结构说明
参数名称 |
参数类型 |
是否必选 |
描述 |
示例值 |
dtsId |
String |
是 |
任务ID |
dtsxxxyyyzzz |
请求示例
POST /v1/task/{dtsId}/config
Host: dts.baidubce.com
ContentType: application/json
Authorization: authorization string
{
"type": "migration",
"granularity" : "instance",
"schemaMapping" : [ {
"dst" : "test.table_dst",
"src" : "test.table_src",
"where" : "where",
"type" : "table"
} ],
"dataType" : [ "base" ],
"srcConnection" : {
"dbPass" : "dbPass",
"dbPort" : 3306,
"instanceId" : "rdsmfgdti3d53f5",
"instanceType" : "bcerds",
"dbUser" : "_dts_trans_",
"field_whitelist" : "field_whitelist",
"dbType" : "mysql",
"dbHost" : "192.168.1.1",
"field_blacklist" : "field_blacklist",
"region" : "bj"
}
}
响应示例
HTTP/1.1 200 OK
{
"dtsId" : "dtsxxxyyyzzz"
}