CreateMigrateJob

Last updated: 2020-03-16 10:30:50

PDF

1. API Description

Domain name for API request: dts.tencentcloudapi.com.

This API (CreateMigrateJob) is used to create a data migration task.

For a finance zone linkage, please use the domain name dts.ap-shenzhen-fsi.tencentcloudapi.com.

A maximum of 20 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: dts.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: CreateMigrateJob.
Version Yes String Common parameter. The value used for this API: 2018-03-30.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
JobName Yes String Data migration task name
MigrateOption Yes MigrateOption Migration task configuration options
SrcDatabaseType Yes String Source instance database type, which currently supports MySQL, Redis, MongoDB, PostgreSQL, MariaDB, and Percona. For more information on the supported types in a specific region, see the migration task creation page in the console.
SrcAccessType Yes String Source instance access type. Valid values: extranet (public network), cvm (CVM-based self-created instance), dcg (Direct Connect-enabled instance), vpncloud (Tencent Cloud VPN-enabled instance), cdb (TencentDB instance), ccn (CCN instance)
SrcInfo Yes SrcInfo Source instance information, which is correlated with the migration task type
DstDatabaseType Yes String Target instance access type, which currently supports MySQL, Redis, MongoDB, PostgreSQL, MariaDB, and Percona. For more information on the supported types in a specific region, see the migration task creation page in the console.
DstAccessType Yes String Target instance access type, which currently only supports cdb (TencentDB instance)
DstInfo Yes DstInfo Destination instance information
DatabaseInfo No String Information of the source table to be migrated, which is described in JSON string format. It is required if MigrateOption.MigrateObject is 2 (migrating the specified table).
For databases with a database-table structure:
[{Database:db1,Table:[table1,table2]},{Database:db2}]
For databases with a database-schema-table structure:
[{Database:db1,Schema:s1
Table:[table1,table2]},{Database:db1,Schema:s2
Table:[table1,table2]},{Database:db2,Schema:s1
Table:[table1,table2]},{Database:db3},{Database:db4
Schema:s1}]

3. Output Parameters

Parameter Name Type Description
JobId String Data migration task ID
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating a public network data migration task

This examples shows you how to fully migrate the data from a public network MySQL instance in Guangzhou to the instance cdb-e78e0nnv in Shanghai and perform a full data consistency check.

Input Example

https://dts.tencentcloudapi.com/?Action=CreateMigrateJob
&JobName=usertest                               // DTS task name
&SrcDatabaseType=mysql                          // Source instance type: mysql
&SrcAccessType=extranet                         // Migration over the public network
&DstDatabaseType=mysql                          // Target instance type: mysql
&DstAccessType=cdb                              // Target instance access type: TencentDB for MySQL
&MigrateOption.RunMode=1                        // Execute immediately
&MigrateOption.MigrateType=2                      // Full
&MigrateOption.MigrateObject=1                  // Entire instance migration
&MigrateOption.ConsistencyType=2                // Full data consistency check
&MigrateOption.IsOverrideRoot=0                    // Do not overwrite the root of the target database
&SrcInfo.Ip=14.17.22.36                         // Public IP of the source instance
&SrcInfo.Port=10301                             // Public port of the source instance
&SrcInfo.User=root                              // Source instance username
&SrcInfo.Supplier=others                        // Migrate a non-Alibaba Cloud instance
&SrcInfo.Password=123456                        // Password of the source instance
&SrcInfo.Region=ap-guangzhou                     // Source instance region: Guangzhou
&DstInfo.InstanceId=cdb-e78e0nnv                //  Target instance ID
&DstInfo.Region=ap-shanghai                     // Target region: Shanghai
&DstInfo.ReadOnly=1                             // The target instance is read-only
&<common request parameters>

Output Example

{
  "Response": {
    "JobId": "dts-1kl0iy0v",
    "RequestId": "2201c42a-714f-4faa-915b-a51cc09f5cec"
  }
}

Example2 Creating a Direct Connect Data Migration Task

This example shows you how to fully and incrementally migrate a Direct Connect-enabled MySQL instance in Guangzhou to the instance cdb-d0dqi8nv in Shanghai and spot check the data consistency.

Input Example

https://dts.tencentcloudapi.com/?Action=CreateMigrateJob
&JobName=usertest                                    // DTS task name
&SrcDatabaseType=mysql                               // Source instance type: mysql
&SrcAccessType=dcg                                   // Migration over the public network
&DstDatabaseType=mysql                                  // Target instance type: mysql
&DstAccessType=cdb                                   // Target instance type: TencentDB for MySQL
&MigrateOption.RunMode=1                               // Execute immediately
&MigrateOption.MigrateType=3                          // Full + incremental migration
&MigrateOption.MigrateObject=1                          // Entire instance migration
&MigrateOption.ConsistencyType=3                        // Spot check
&MigrateOption.ConsistencyParams.SelectRowsPerTable=10    // Randomly select 20% of tables and 10% of entries in each table for data content check
&MigrateOption.ConsistencyParams.TablesSelectAll=20
&MigrateOption.ConsistencyParams.TablesSelectCount=30     // Randomly select 30% of tables for entry quantity check, i.e., Select count(*)
&MigrateOption.IsOverrideRoot=0                     // Do not overwrite the root of the target database
&SrcInfo.UniqDcgId=dcg-cyrjcc09                      // Direct Connect Gateway ID
&SrcInfo.VpcId=vpc-72jblfaa                           //  VPC ID
&SrcInfo.SubnetId=subnet-7raec42a                   // Subnet ID
&SrcInfo.Ip=192.168.120.136                         // IP of the source instance
&SrcInfo.Port=3307                                  // Port of the source instance
&SrcInfo.User=root                                  //Source instance username
&SrcInfo.Supplier=others                            // Migrate a non-Alibaba Cloud instance
&SrcInfo.Password=123456                            // Password of the source instance
&SrcInfo.Region=ap-guangzhou                          // Source instance region: Guangzhou
&DstInfo.InstanceId=cdb-d0dqi8nv                       // Target instance ID
&DstInfo.Region=ap-shanghai                            // Target region: Shanghai
&DstInfo.ReadOnly=1                                 // The target instance is read-only
&<common request parameters>

Output Example

{
  "Response": {
    "JobId": "dts-o3s1vxsp",
    "RequestId": "915bc42a-714f-4faa-915b-a51cc09f5714"
  }
}

Example3 Creating a database migration task

Perform structural migration of selected tables from one MySQL instance to another MySQL instance on Tencent Cloud without performing data consistency check.

Input Example

https://dts.tencentcloudapi.com/?Action=CreateMigrateJob
&JobName=usertest                                    // DTS task name
&SrcDatabaseType=mysql                                // Source instance type: mysql
&SrcAccessType=cdb                                   // Database migration
&DstDatabaseType=mysql                               // Target instance type: mysql
&DstAccessType=cdb                                   // Target instance type: TencentDB for MySQL
&MigrateOption.RunMode=1                               // Execute immediately
&MigrateOption.MigrateType=1                          // Structural migration
&MigrateOption.MigrateObject=2                       // Migrate the specified tables
&DatabaseInfo=[{"Database":"test","Table":["user","log"]}]    // Table to be migrated
&MigrateOption.ConsistencyType=5                       // No check
&SrcInfo.InstanceId=cdb-powiqx8q                     // Source instance ID
&SrcInfo.User=root                                   // Source instance username
&SrcInfo.Supplier=others                            // Migrate a non-Alibaba Cloud instance
&SrcInfo.Password=123456                               // Password of the source instance
&SrcInfo.Region=ap-guangzhou                           // Source instance region: Guangzhou
&DstInfo.InstanceId=cdb-d0dqi8nv                      // Target instance ID
&DstInfo.Region=ap-shanghai                          // Target region: Shanghai
&<common request parameters>

Output Example

{
  "Response": {
    "JobId": "dts-46i7easd",
    "RequestId": "bc94c57b-9d69-11e9-84cb-256e968056b0"
  }
}

Example4 Creating a public network migration task for RDS

This example shows you how to migrate an RDS 5.6 instance fully and incrementally over the public network.

Input Example

https://dts.tencentcloudapi.com/?Action=CreateMigrateJob
&JobName=usertest                                    // DTS task name
&SrcDatabaseType=mysql                                // Source instance type: mysql
&SrcAccessType=extranet                         // Migration over the public network
&DstDatabaseType=mysql                               // Target instance type: mysql
&DstAccessType=cdb                                   // Target instance type: TencentDB for MySQL
&MigrateOption.RunMode=1                               // Execute immediately
&MigrateOption.MigrateType=3                          // Full + incremental migration
&MigrateOption.MigrateObject=1                       // Migrate the entire instance
&MigrateOption.ConsistencyType=5                       // No check
&SrcInfo.AccessKey=cdb-powiqx8q                         // Alibaba Cloud AccessKey
&SrcInfo.RdsInstanceId=rm-uf546i98x6ngqjnjx              // Alibaba Cloud ApsaraDB for RDS instance ID
&SrcInfo.Ip=106.13.216.14
&SrcInfo.Port=3306
&SrcInfo.User=root                                   // Source instance username
&SrcInfo.Supplier=aliyun                             // Migrate an Alibaba Cloud instance
&SrcInfo.Password=123456                               // Password of the source instance
&SrcInfo.Region=ap-guangzhou                           // Source instance region: Guangzhou
&DstInfo.InstanceId=cdb-d0dqi8nv                      // Target instance ID
&DstInfo.Region=ap-shanghai                          // Target region: Shanghai
&<common request parameters>

Output Example

{
  "Response": {
    "JobId": "dts-p01oy6qp",
    "RequestId": "2fcd891c-32f4-bf82-a8c0-16c99d75e175"
  }
}

5. Developer Resources

API Explorer

This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.NotAllowOperation This operation is prohibited.
InternalError.DatabaseError Failed to access the database on the DTS platform.
InternalError.DuplicateJob Migration tasks are in conflict.
InternalError.ProtocolError Communication protocol error.
InvalidParameter Invalid parameter.
LimitExceeded.MaxUnusedJobs The number of idle migration tasks exceeds the limit.
UnauthorizedOperation.NotEnoughPrivileges Verification failed. Insufficient permissions.