更新时间:2024-03-14 GMT+08:00
分享

批量创建任务

功能介绍

根据请求参数不同,可以批量创建实时迁移、实时同步、实时灾备任务。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

接口约束

为保证接口调用性能,建议批量调用数量不超过10个。

URI

POST /v3/{project_id}/jobs/batch-creation

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

租户在某一Region下的Project ID。

获取方法请参见获取项目ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Content-Type

String

指定类型为application/json。

缺省值:application/json

X-Auth-Token

String

从IAM服务获取的用户Token。

X-Language

String

请求语言类型,缺省值:en-us

取值:

  • en-us
  • zh-cn
表3 请求Body参数

参数

是否必选

参数类型

描述

jobs

Array of objects

创建任务请求体。

详情请参见表4

表4 jobs字段数据结构说明

参数

是否必选

参数类型

描述

name

String

任务名称,约束:任务名称在4位到50位之间,不区分大小写,可以包含字母、数字、中划线或下划线,不能包括其他特殊字符。

  • 最小长度:4
  • 最大长度:50

db_use_type

String

迁移场景。

取值:

  • migration:实时迁移
  • sync:实时同步
  • cloudDataGuard:实时灾备

engine_type

String

DRS任务引擎类型。

取值:

  • mysql:MySQL到MySQL迁移,MySQL到MySQL同步
  • mongodb:MongoDB到DDS迁移
  • cloudDataGuard-mysql:MySQL到MySQL灾备
  • gaussdbv5GaussDB同步
  • mysql-to-kafka:MySQL到Kafka同步
  • taurus-to-kafka:GaussDB(for MySQL)到Kafka同步
  • gaussdbv5ha-to-kafkaGaussDB主备版到Kafka同步
  • postgresql:PostgreSQL到PostgreSQL同步

详细取值可参考引擎类型说明

job_direction

String

任务方向。

取值:

  • up:入云 ,灾备场景时对应本云为备。
  • down:出云,灾备场景时对应本云为主。
  • non-dbs:自建。

bind_eip

Boolean

是否绑定EIP,网络类型为EIP时必填且为true。

customize_sutnet_id

String

DRS实例所在子网ID,对应目标库相同VPC下已创建的子网(subnet)的网络ID,UUID格式。

product_id

String

产品ID。

is_target_readonly

Boolean

指定目标实例是否限制为只读,MySQL迁移和灾备,且job_direction为up时设置有效。(灾备场景下,单主灾备且本云为备为必填且为true,不填默认设置为true)。

net_type

String

网络类型。取值:

  • vpn
  • vpc
  • eip

灾备场景不支持选择VPC网络。

node_type

String

规格类型。取值:high

node_num

Integer

节点个数。

MongoDB数据库时对应源端分片个数,源库为集群时必填,[1-32],MySQL双主灾备时会默认设置为2。

MongoDB数据库时对应源端分片个数,源库为集群时必填,[1-32]。

source_endpoint

Object

源库信息。

详情请参见表5

target_endpoint

Object

目标库信息。

详情请参见表5

task_type

String

任务模式,缺省值:FULL_INCR_TRANS

取值:

  • FULL_TRANS:全量
  • FULL_INCR_TRANS:全量+增量
  • INCR_TRANS:增量

单主灾备场景仅支持选择全量加增量(FULL_INCR_TRANS)。

tags

Array of object

标签信息,最多添加20个标签。

详情请参见表6

description

String

任务描述。 约束:任务描述不能超过256位,且不能包含!<>&'"\特殊字符。

multi_write

Boolean

  • db_use_type 是cloudDataGuard时,必填,灾备类型是双主灾备时 multi_write取值true, 否则为false。
  • db_use_type 是其他类型时,multi_write是非必选参数。

缺省值:false

sys_tags

Array of object

企业项目,不填默认为default,key值必须为_sys_enterprise_project_id,value为企业项目ID,只能有一个企业项目。

详情请参见表6

expired_days

String

任务处于异常状态一段时间后,将会自动结束。单位为天。(范围14-100),不传默认为14天。

master_az

String

主备任务主任务所在可用区code,可以通过查询规格未售罄的可用区接口获取

  • master_az和slave_az同时填写时生效。
  • 目前支持mysql,gaussdbv5ha-to-kafka。

slave_az

String

主备任务备任务所在可用区code,可以通过查询规格未售罄的可用区接口获取

  • master_az和slave_az同时填写时生效。
  • 目前支持mysql,gaussdbv5ha-to-kafka。

charging_mode

String

计费模式,不填默认为按需计费。

取值范围:

  • period:包年包月。
  • on_demand:按需计费。
    说明:
    • db_use_type为migration时不支持包年包月。
    • 支持的engine_type为:mysql,cloudDataGuard-mysql,postgresql,gaussdbv5ha-to-kafka

period_order

Object

包年包月信息。

详情请参见表7

说明:

charging_mode为period时必填。

public_ip_list

Array of objects

指定公网IP的信息。

详情请参见表8

表5 source_endpoint和target_endpoint字段数据结构说明

参数

是否必选

参数类型

描述

db_type

String

数据库类型。取值:

  • mysql:MySQL
  • mongodb:MongoDB
  • gaussdbv5:GaussDB分布式版
  • taurus:GaussDB(for MySQL)
  • gaussdbv5ha:GaussDB主备版
  • kafka:Kafka
  • postgresql:PostgreSQL

az_code

String

数据库所在可用区azCode。

region

String

数据库实例所在Region。数据库为云上实例时,比如RDS实例时必填(灾备场景下job_direction为down时source_endpoint中该值为必填,job_direction为up时target_endpoint中该值为必填)。

inst_id

String

数据库实例ID。数据库为云上实例时,比如RDS实例时必填(灾备场景下job_direction为down时source_endpoint中该值为必填,job_direction为up时target_endpoint中该值为必填)。

vpc_id

String

数据库所在的虚拟私有云ID。

subnet_id

String

数据库所在的子网ID。

security_group_id

String

数据库所在的安全组ID。

project_id

String

RDS实例的Project ID。

db_name

String

服务名serviceName,源库为Oracle场景时必填。约束:不能超过128位,不能包含!<>&'"\特殊字符。

db_password

String

数据库密码。

db_port

Integer

数据库端口。约束:输入范围为1-65535之间的整数。

db_user

String

数据库用户。

inst_name

String

RDS实例名称。

ip

String

数据库IP。

mongo_ha_mode

String

mongo ha模式。

safe_mode

Integer

MRS集群运行模式,取值:

  • 0普通集群
  • 1安全集群

ssl_cert_password

String

SSL证书密码,证书文件后缀为.p12。

ssl_cert_check_sum

String

SSL证书内容checksum值,后端校验,源库安全连接必选。

ssl_cert_key

String

SSL证书内容,用base64加密。

ssl_cert_name

String

SSL证书名字。

ssl_link

Boolean

是否SSL安全连接。

topic

String

kafka topic名称。

cluster_mode

String

MongoDB集群4.0及以上版本,当集群实例无法获取到分片节点的IP时,source_endpoint中需要填写,值为:Sharding4.0+。

缺省值:Sharding4.0+

取值:Sharding4.0+

表6 tags和sys_tags字段数据结构说明

参数

是否必选

参数类型

描述

key

String

标签键,最大长度36,只能包含字母、数字、下划线、中划线和中文。

value

String

标签值,最大长度43,只能包含字母、数字、下划线、中划线和中文。

表7 period_order字段数据结构说明

参数

是否必选

参数类型

描述

period_type

Integer

订购周期类型。

取值范围:

  • 2:表示周期类型为月。
  • 3:表示周期类型为年。
    说明:

    charging_mode为period时生效且为必选值。

period_num

Integer

订购周期数。

取值范围:

  • period_type=2(周期类型为月)时,取值为[1,9]。
  • period_type=3(周期类型为年)时,取值为[1,3]。
    说明:
    • charging_mode为period时生效且为必选值。
    • period_num为正整数。

is_auto_renew

Integer

是否自动续订。

取值范围:

  • 0:表示不自动续订。
  • 1:表示自动续订。
    说明:

    charging_mode为period时生效,不传该字段时默认为不自动续订。

表8 public_ip_list字段数据结构说明

参数

是否必选

参数类型

描述

id

String

指定公网IP的ID。

public_ip

String

指定公网IP。

type

String

指定公网IP绑定任务的类型:

  • 主备任务:主是master,备是slave。
  • 其他固定为master。

枚举值:

  • master
  • slave

响应参数

状态码: 202

表9 响应Body参数

参数

参数类型

描述

results

Array of objects

批量创建任务的响应体集合。

详情请参见表10

count

Integer

总记录数。

表10 results字段数据结构说明

参数

参数类型

描述

id

String

任务ID。

child_ids

Array of strings

子任务ID集合,有子任务时返回该字段。

name

String

任务名称。

status

String

任务状态。

create_time

String

创建时间,时间戳。

error_code

String

错误码。

error_msg

String

错误信息。

请求示例

  • 批量创建MySQL入云实时迁移任务,任务模式为全量+增量,网络类型为公网网络
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-9228",
        "node_type" : "high",
        "engine_type" : "mysql",
        "net_type" : "eip",
        "job_direction" : "up",
        "db_use_type" : "migration",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "352ad828-3467-4f03-987a-c55a5a9dd417",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "cn-xianhz-1",
          "db_type" : "mysql",
          "inst_id" : "e05a3679efe241d8b5dee80b17c1a863in01"
        },
        "is_target_readonly" : false,
        "bind_eip" : true
      } ]
    }
  • 批量创建MySQL本云为备实时灾备任务,网络类型为公网网络
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-api-test",
        "engine_type" : "cloudDataGuard-mysql",
        "net_type" : "eip",
        "node_type" : "high",
        "job_direction" : "up",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "cn-xianhz-1",
          "db_type" : "mysql",
          "inst_id" : "e05a3679efe241d8b5dee80b17c1a863in01",
          "project_id" : "054ba152d480d55b2f5dc0069e7ddef0"
        },
        "is_target_readonly" : true,
        "bind_eip" : true,
        "db_use_type" : "cloudDataGuard",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "352ad828-3467-4f03-987a-c55a5a9dd417",
        "multi_write" : false
      } ]
    }
  • 批量创建DDS副本入云实时迁移任务,任务模式为全量+增量,网络类型为公网网络
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-3371-linxiaolu",
        "node_type" : "high",
        "engine_type" : "mongodb",
        "net_type" : "eip",
        "job_direction" : "up",
        "db_use_type" : "migration",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "faf513f3-7a88-4a5c-bec7-238699c29c17",
        "source_endpoint" : {
          "db_type" : "mongodb"
        },
        "target_endpoint" : {
          "region" : "cn-xianhz-1",
          "db_type" : "mongodb",
          "inst_id" : "3cadd5a0ef724f55ac7fa5bcb5f4fc5fin02"
        },
        "bind_eip" : true
      } ]
    }
  • 创建MySQL主备入云同步任务,任务模式为全量+增量,网络类型为公网网络
    https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-creation
    
    {
      "jobs" : [ {
        "name" : "DRS-linxiaolu-test3",
        "engine_type" : "mysql",
        "net_type" : "eip",
        "node_type" : "high",
        "job_direction" : "up",
        "source_endpoint" : {
          "db_type" : "mysql"
        },
        "target_endpoint" : {
          "region" : "cn-xianhz-1",
          "db_type" : "mysql",
          "inst_id" : "64e8d7a31afa476ca85609a17af83765in01",
          "project_id" : "054ba152d480d55b2f5dc0069e7ddef0"
        },
        "bind_eip" : true,
        "db_use_type" : "sync",
        "task_type" : "FULL_INCR_TRANS",
        "customize_sutnet_id" : "0cf77cfb-3785-4065-a9c4-74b7bb2df071",
        "master_az" : "az2xahz",
        "slave_az" : "az3xahz"
      } ]
    }

响应示例

状态码: 202

Accepted

{
  "results" : [ {
    "id" : "e11eaf8f-71ef-4fad-8890-aed7572ajb11",
    "name" : "DRS-9228",
    "status" : "CREATING",
    "create_time" : "1599188556112"
  } ],
  "count" : 1
}

状态码

状态码

描述

202

Accepted

400

Bad Request

错误码

请参见错误码

分享:

    相关文档

    相关产品