Configure DTS tasks with OpenAPI

Updated at:

Configure DTS synchronization, migration, and subscription tasks by calling API operations.

Overview

Configuring DTS tasks by calling API operations works the same way as in the DTS console. Two workflows are available: purchase an instance first and then configure it, or configure a task first and then purchase an instance.

  • Purchase first, then configure:

    • Synchronization or migration tasks: Whether precheck starts depends on autoStartModulesAfterConfig in the Reserve parameter reference) of the ConfigureDtsJob operation.

    • Subscription tasks: Precheck does not start by default.

  • Configure first, then purchase:

    Whether precheck starts depends on AutoStart in the CreateDtsInstance operation.

Usage notes

  • Ensure that all parameters are correctly specified. Incorrect parameters cause API call failures.

  • For the purchase-first workflow with synchronization or migration tasks, if precheck passes without errors, DTS automatically executes all subsequent modules.

Prerequisites

Collect the source database instance information: instance ID, region, endpoint or IP address, port, database account, and password.

Procedure

Note

The following examples use a migration task.

Scenario 1: Purchase an instance first and then configure it

Do not start the precheck module

  1. Call the CreateDtsInstance operation to purchase a DTS instance.

    Sample requests

    {
      "DestinationEndpointEngineName":"MySQL",
      "DestinationRegion":"cn-hangzhou",
      "InstanceClass":"small",
      "PayType":"PostPaid",
      "RegionId":"cn-hangzhou",
      "SourceEndpointEngineName":"MySQL",
      "SourceRegion":"cn-hangzhou",
      "Type":"MIGRATION"
    }

    Sample responses

    {
      "RequestId": "76C0****-879D-5FB7-8F08-BC11B67C****",
      "InstanceId": "dtsza0i4l8x167****",
      "Success": true,
      "JobId": "za0i4l8x167****"
    }
  2. Call the ConfigureDtsJob operation to configure a DTS task.

    Note

    Sample requests

    {
      "DataInitialization":"true",
      "DataSynchronization":"false",
      "DestinationEndpointInstanceType":"RDS",
      "DtsJobName":"rdsmysql_to_rdsmysql",
      "JobType":"MIGRATION",
      "SourceEndpointInstanceType":"RDS",
      "StructureInitialization":"true",
      "DbList":{
        "dtsdb":{
          "name":"dtsdb_1",
          "all":"false",
          "Table":{
            "person":{
              "name":"person",
               "all":"true"
            }
          }
        }
      },
      "DestinationEndpointEngineName":"MYSQL",
      "DestinationEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "DestinationEndpointPassword":"**********",
      "DestinationEndpointRegion":"cn-hangzhou",
      "DestinationEndpointUserName":"dtstest",
      "DtsInstanceId":"dtsza0i4l8x167****",
      "RegionId":"cn-hangzhou",
      "Reserve":{
        "targetTableMode":"0",
        "autoStartModulesAfterConfig":"none"
      },
      "SourceEndpointDatabaseName":"dtsdb",
      "SourceEndpointEngineName":"MYSQL",
      "SourceEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "SourceEndpointPassword":"**********",
      "SourceEndpointRegion":"cn-hangzhou",
      "SourceEndpointUserName":"dtstest"
    }

    Sample responses

    {
      "DtsJobId": "za0i4l8x167****",
      "RequestId": "9233****-9539-5DB7-B801-69AADEB9****",
      "HttpStatusCode": 200,
      "DtsInstanceId": "dtsza0i4l8x167****",
      "Success": true
    }
  3. Optional. Call the StartDtsJob operation to start the DTS task as needed. DTS then executes the precheck module and subsequent modules.

    Sample requests

    {
    "DtsJobId":"za0i4l8x167****",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "CE51****-40F3-5913-AA27-C50251E2****",
      "HttpStatusCode": 200,
      "Success": true
    }

Start the precheck module

Note

Not applicable to subscription tasks.

  1. Call the CreateDtsInstance operation to purchase a DTS instance.

    Sample requests

    {
      "DestinationEndpointEngineName":"MySQL",
      "DestinationRegion":"cn-hangzhou",
      "InstanceClass":"small",
      "PayType":"PostPaid",
      "RegionId":"cn-hangzhou",
      "SourceEndpointEngineName":"MySQL",
      "SourceRegion":"cn-hangzhou",
      "Type":"MIGRATION"
    }

    Sample responses

    {
      "RequestId": "63F4****-935A-5E55-A7BC-D0464BA1****",
      "InstanceId": "dtsdg6e4m0e177****",
      "Success": true,
      "JobId": "dg6e4m0e177****"
    }
  2. Call the ConfigureDtsJob operation to configure a DTS task.

    Note
    • Leave the dulesAfterConfig parameter unspecified or set it to auto in the Reserve parameter reference.

    • If precheck passes without errors, DTS automatically executes all subsequent modules.

    Sample requests

    {
      "DataInitialization":"true",
      "DataSynchronization":"false",
      "DestinationEndpointInstanceType":"RDS",
      "DtsJobName":"rdsmysql_to_rdsmysql_1",
      "JobType":"MIGRATION",
      "SourceEndpointInstanceType":"RDS",
      "StructureInitialization":"true",
      "DbList":{
        "dtsdb":{
          "name":"dtsdb_1",
          "all":"false",
          "Table":{
            "person":{
              "name":"person_1",
               "all":"true"
            }
          }
        }
      },
      "DestinationEndpointEngineName":"MYSQL",
      "DestinationEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "DestinationEndpointPassword":"**********",
      "DestinationEndpointRegion":"cn-hangzhou",
      "DestinationEndpointUserName":"dtstest",
      "DtsInstanceId":"dtsdg6e4m0e177****",
      "RegionId":"cn-hangzhou",
      "SourceEndpointDatabaseName":"dtsdb",
      "SourceEndpointEngineName":"MYSQL",
      "SourceEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "SourceEndpointPassword":"**********",
      "SourceEndpointRegion":"cn-hangzhou",
      "SourceEndpointUserName":"dtstest"
    }

    Sample responses

    {
      "DtsJobId": "za0i4l8x167****",
      "RequestId": "9233****-9539-5DB7-B801-69AADEB9****",
      "HttpStatusCode": 200,
      "DtsInstanceId": "dtsza0i4l8x167****",
      "Success": true
    }

Scenario 2: Configure a task first and then purchase an instance

+Do not start the precheck module

  1. Call the ConfigureDtsJob operation to configure a DTS task.

    Note

    For subscription tasks, you need to call the ConfigureSubscription operation.

    Sample requests

    {
      "DataInitialization":"true",
      "DataSynchronization":"false",
      "DestinationEndpointInstanceType":"RDS",
      "DtsJobName":"rdsmysql_to_rdsmysql_2",
      "JobType":"MIGRATION",
      "SourceEndpointInstanceType":"RDS",
      "StructureInitialization":"true",
      "DbList":{
        "dtsdb":{
          "name":"dtsdb_1",
          "all":"false",
          "Table":{
            "person":{
              "name":"person_2",
               "all":"true"
            }
          }
        }
      },
      "DestinationEndpointEngineName":"MYSQL",
      "DestinationEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "DestinationEndpointPassword":"**********",
      "DestinationEndpointRegion":"cn-hangzhou",
      "DestinationEndpointUserName":"dtstest",
      "RegionId":"cn-hangzhou",
      "Reserve":{
        "targetTableMode":"0",
        "autoStartModulesAfterConfig":"none"
      },
      "SourceEndpointDatabaseName":"dtsdb",
      "SourceEndpointEngineName":"MYSQL",
      "SourceEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "SourceEndpointPassword":"**********",
      "SourceEndpointRegion":"cn-hangzhou",
      "SourceEndpointUserName":"dtstest"
    }

    Sample responses

    {
      "DtsJobId": "w4rg4pj4169****",
      "RequestId": "F0CC****-A556-5A9D-AFF0-85D2B284****",
      "HttpStatusCode": 200,
      "Success": true
    }
  2. Optional. Start the DTS task as needed. DTS then executes the precheck module and subsequent modules. For more information, see step 2 and beyond of Start the precheck module without starting the DTS task or Start the precheck module and the DTS task.

Start the precheck module without starting the DTS task

  1. Call the ConfigureDtsJob operation to configure a DTS task.

    Note

    For subscription tasks, you need to call the ConfigureSubscription operation.

    Sample requests

    {
      "DataInitialization":"true",
      "DataSynchronization":"false",
      "DestinationEndpointInstanceType":"RDS",
      "DtsJobName":"rdsmysql_to_rdsmysql_3",
      "JobType":"MIGRATION",
      "SourceEndpointInstanceType":"RDS",
      "StructureInitialization":"true",
      "DbList":{
        "dtsdb":{
          "name":"dtsdb_1",
          "all":"false",
          "Table":{
            "person":{
              "name":"person_3",
               "all":"true"
            }
          }
        }
      },
      "DestinationEndpointEngineName":"MYSQL",
      "DestinationEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "DestinationEndpointPassword":"**********",
      "DestinationEndpointRegion":"cn-hangzhou",
      "DestinationEndpointUserName":"dtstest",
      "RegionId":"cn-hangzhou",
      "SourceEndpointDatabaseName":"dtsdb",
      "SourceEndpointEngineName":"MYSQL",
      "SourceEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "SourceEndpointPassword":"**********",
      "SourceEndpointRegion":"cn-hangzhou",
      "SourceEndpointUserName":"dtstest"
    }

    Sample responses

    {
      "DtsJobId": "w4rg4pj4169****",
      "RequestId": "F0CC****-A556-5A9D-AFF0-85D2B284****",
      "HttpStatusCode": 200,
      "Success": true
    }
  2. Call the StartDtsJob operation to start the precheck module.

    Sample requests

    {
    "DtsJobId":"w4rg4pj4169****",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "2A54****-4467-520E-B45A-D144A0C8****",
      "HttpStatusCode": 200,
      "Success": true
    }
  3. Call the DescribePreCheckStatus operation to check the execution status of the precheck module.

    Sample requests

    {
    "DtsJobId":"w4rg4pj4169****",
    "JobCode":"01",
    "RegionId":"cn-hangzhou",
    "StructType":"before"
    }

    Sample responses

    The following response indicates that precheck completed without errors.

    {
      ******
      "AnalysisJobProgress": [],
      "PageRecordCount": 20,
      "RequestId": "4436****-EE62-5DC3-8838-30807292****",
      "FullNetCheckJobStatus": [],
      "JobName": "****",
      "ErrorItem": 0,
      "SubDistributedJobStatus": [],
      "Code": "01",
      "Success": true,
      "PageNumber": 1,
      "State": "Finished",
      "Total": 9,
      "HttpStatusCode": 200,
      "JobId": "w4rg4pj4169****",
      ******
    }
  4. Call the CreateDtsInstance operation to purchase a DTS instance.

    Note

    Leave the AutoStart parameter unspecified or set it to false. The DTS instance then does not execute subsequent modules. This is equivalent to clicking Buy and Save in the DTS console.

    Sample requests

    {
    "InstanceClass":"small",
    "JobId":"w4rg4pj4169****",
    "PayType":"PostPaid",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "63F4****-935A-5E55-A7BC-D0464BA1****",
      "InstanceId": "dtsgvbn4c28167****",
      "Success": true,
      "JobId": "w4rg4pj4169****"
    }
  5. Optional. Call the StartDtsJob operation to start the DTS task as needed.

    Sample requests

    {
    "DtsJobId":"w4rg4pj4169****",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "EC1F****-10B0-501E-8B3E-71963809****",
      "HttpStatusCode": 200,
      "Success": true
    }

Start the precheck module and the DTS task

  1. Call the ConfigureDtsJob operation to configure a DTS task.

    Note

    For subscription tasks, you need to call the ConfigureSubscription operation.

    Sample requests

    {
      "DataInitialization":"true",
      "DataSynchronization":"false",
      "DestinationEndpointInstanceType":"RDS",
      "DtsJobName":"rdsmysql_to_rdsmysql_4",
      "JobType":"MIGRATION",
      "SourceEndpointInstanceType":"RDS",
      "StructureInitialization":"true",
      "DbList":{
        "dtsdb":{
          "name":"dtsdb_1",
          "all":"false",
          "Table":{
            "person":{
              "name":"person_4",
               "all":"true"
            }
          }
        }
      },
      "DestinationEndpointEngineName":"MYSQL",
      "DestinationEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "DestinationEndpointPassword":"**********",
      "DestinationEndpointRegion":"cn-hangzhou",
      "DestinationEndpointUserName":"dtstest",
      "RegionId":"cn-hangzhou",
      "SourceEndpointDatabaseName":"dtsdb",
      "SourceEndpointEngineName":"MYSQL",
      "SourceEndpointInstanceID":"rm-bp1072qxu5q3h****",
      "SourceEndpointPassword":"**********",
      "SourceEndpointRegion":"cn-hangzhou",
      "SourceEndpointUserName":"dtstest"
    }

    Sample responses

    {
      "DtsJobId": "etom45sg17e****",
      "RequestId": "46F2****-69DD-59D7-8FF5-A119D72A****",
      "HttpStatusCode": 200,
      "Success": true
    }
  2. Call the StartDtsJob operation to start the precheck module.

    Sample requests

    {
    "DtsJobId":"etom45sg17e****",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "2A54****-4467-520E-B45A-D144A0C8****",
      "HttpStatusCode": 200,
      "Success": true
    }
  3. Call the DescribePreCheckStatus operation to check the execution status of the precheck module.

    Sample requests

    {
    "DtsJobId":"etom45sg17e****",
    "JobCode":"01",
    "RegionId":"cn-hangzhou",
    "StructType":"before"
    }

    Sample responses

    The following response indicates that precheck completed without errors.

    {
      ******
      "AnalysisJobProgress": [],
      "PageRecordCount": 20,
      "RequestId": "4436****-EE62-5DC3-8838-30807292****",
      "FullNetCheckJobStatus": [],
      "JobName": "****",
      "ErrorItem": 0,
      "SubDistributedJobStatus": [],
      "Code": "01",
      "Success": true,
      "PageNumber": 1,
      "State": "Finished",
      "Total": 9,
      "HttpStatusCode": 200,
      "JobId": "etom45sg17e****",
      ******
    }
  4. Call the CreateDtsInstance operation to purchase a DTS instance.

    Note

    Set the AutoStart parameter to true. DTS then automatically executes subsequent modules. This is equivalent to clicking Buy and Save in the DTS console.

    Sample requests

    {
    "AutoStart":"true",
    "InstanceClass":"small",
    "JobId":"etom45sg17e****",
    "PayType":"PostPaid",
    "RegionId":"cn-hangzhou"
    }

    Sample responses

    {
      "RequestId": "4280****-9D5C-5053-9CA3-FAE47248****",
      "InstanceId": "dtst7lg4f20178****",
      "Success": true,
      "JobId": "etom45sg17e****"
    }

References