Migrate a self-managed database to an ECS instance

Updated at:

In this tutorial, you use Data Transmission Service (DTS) to configure a data migration task that moves data from an on-premises self-managed MySQL database to a self-managed MySQL database on an Elastic Compute Service (ECS) instance. DTS supports data interaction between various data sources, including RDBMS, NoSQL, and OLAP.

Prerequisites

  • An ECS instance is created. For more information, see Create an instance by using the custom launch tab.

  • Traffic on the default MySQL port (3306) is allowed in the security group of the ECS instance. For more information, see Add a security group rule.

  • A MySQL database is installed on the ECS instance. For more information, see Deploy a database.

  • Non-root database accounts are created for both the on-premises MySQL database and the MySQL database on the ECS instance.

    For example, run the following commands to create the dts account with the password Test@123456 for a MySQL database:

    # Step 1: Create a user and set a password.
    CREATE USER 'dts'@'%' IDENTIFIED BY 'Test@123456';
    
    # Step 2: Grant privileges.
    GRANT ALL PRIVILEGES ON *.* TO 'dts'@'%';
    
    # Step 3: Flush privileges.
    FLUSH PRIVILEGES;

Background information

The data migration feature of DTS supports data migration between homogeneous and heterogeneous data sources. DTS also provides various extract, transform, and load (ETL) features, such as data filtering and mapping at the schema, table, and column levels. DTS enables zero-downtime migration. During migration, the source database remains operational to minimize the impact on your business. For more information about the database types that DTS supports, see Data migration.

Procedure

  1. Log on to the DTS console.

  2. In the left-side navigation pane, click Data Migration.

  3. Select the region of the destination ECS instance, and then click Create Migration Task.

  4. Configure the data migration task.

    1. Configure the task name.

      DTS automatically generates a task name. For easier identification, provide a descriptive name. The name does not need to be unique.

    2. Configure the source database.

      Note

      If you have created Data Management (DMS) database instances, you can select an existing instance to quickly configure the source database.

      This example uses a self-managed database with a public IP address. For information about other migration scenarios, see Migration Scenarios Overview.

      ParameterDescription
      Database typeThe type of the on-premises database. In this example, select MySQL.
      Access methodThe method used to connect to the self-managed database. In this example, select Public IP Address.
      Instance regionThe region where you create the DTS task. Select a region that is geographically close to your on-premises database to reduce latency. In this example, select China (Hangzhou).
      Domain name or IP addressThe endpoint of the on-premises database.
      PortThe MySQL listening port. The default value is 3306.
      Database account

      The non-root account for the on-premises MySQL database.

      Important

      You must use a non-root account. Otherwise, the connectivity test fails.

      PasswordThe password of the non-root account.
      EncryptionSelect Non-encrypted or SSL-encrypted based on your requirements. If SSL is not enabled for your self-managed MySQL database, select Non-encrypted. If SSL is enabled, select SSL-encrypted, upload a CA Certificate, and enter the CA Certificate Password.
    3. Configure the destination database.

      ParameterDescription
      Database typeThe same as the source database type. In this example, select MySQL.
      Access methodSelect Self-managed Database on ECS.
      Instance regionThe region of the destination ECS instance. In this example, select China (Beijing).
      ECS Instance IDThe ID of the destination ECS instance. DTS supports ECS instances that are in a VPC.
      PortThe MySQL listening port. The default value is 3306.
      Database account

      The non-root account for the MySQL database on the ECS instance.

      Important

      You must use a non-root account. Otherwise, the connectivity test fails.

      PasswordThe password of the non-root account.
      EncryptionSelect Non-encrypted or SSL-encrypted based on your requirements.
    4. After you complete the configurations, click Test Connectivity and Proceed at the bottom of the page.

      If prompted, add the required DTS IP addresses to the security group rules of the source or destination database before running the test. For more information, see Add a security group rule.

  5. Configure the migration types and objects.

    1. Select the migration types.

    2. Select the objects to migrate.

    3. Click Next: Advanced Settings and configure advanced settings as prompted.

    4. Click Next: Data Verification to configure a data verification task.

  6. Click Next: Save Task Settings and Precheck. After the precheck is successful, click Next: Purchase Instance to confirm your configuration and complete the purchase.

    Before the migration begins, DTS performs a precheck on items such as connectivity, permissions, and log formats. All precheck items pass when the precheck succeeds.

    After you complete the purchase, you can view the status and progress of the migration task on the Data Migration Tasks page. The Status of the migration task displays a green check mark and Completed, which indicates that the data migration task is successful. Completed tasks are free of charge.