Help Center/ Data Replication Service/ Getting Started/ Creating a Real-Time Migration Task
Updated on 2024-11-13 GMT+08:00

Creating a Real-Time Migration Task

With DRS, you can migrate data from source to destination in real time. You create a replication instance to connect to both the source and destination databases and configure objects to be migrated. DRS will help you compare metrics and data between source and destination, so you can determine the best time to switch to the destination database while minimizing service downtime.

This section describes how to migrate full+incremental data from an on-premises MySQL database to a Huawei Cloud RDS for MySQL instance through a public network. For more information about real-time migration, see Migration Overview.

Operation Process

Process

Description

Preparations

Sign up for a HUAWEI ID, complete real-name authentication, enable Huawei Cloud services, and prepare the database to be migrated, the database connection account, and a network.

Step 1: Create a Migration Task

Select the source and destination databases, and create and start a migration task.

Step 2: Query Migration Progress

Check the migration progress.

Step 3: Compare Migration Items

Create a comparison task to check whether the data in the source database is consistent with that in the destination database.

Stopping a Task

After confirming that the data is consistent, cut over workloads and stop the DRS task.

Preparations

Before creating a real-time migration task, prepare the Huawei account, database to be migrated, database connection account, and network environment by referring to the following steps.

Prepare a Huawei account, create a user, and grant permissions to the user to use DRS.

  1. Access Huawei Cloud website.
  2. Click Sign Up and follow the instructions to create your account (your HUAWEI ID).
  3. Select the service agreement and click Enable.

    The system displays a message indicating that Huawei Cloud services have been enabled.

  4. Perform real-name authentication.

  5. For fine-grained permissions management, create an Identity and Access Management (IAM) user and user group on the IAM console and grant the user specific operation permissions. For details, see Creating a User and Granting Permissions

Before creating a real-time migration task, you need to prepare the source and destination databases.

  • The source database in this example is an on-premises MySQL database. Prepare the following source database details:

    Item

    Example Value

    Description

    DB engine version

    MySQL 5.7

    -

    IP address

    10.154.217.42

    Enter an IP address.

    Port

    3306

    -

  • The destination database in this example is a Huawei Cloud RDS for MySQL instance. You need to prepare the database details by referring to Getting Started with RDS for MySQL.

    Item

    Example Value

    Description

    Region

    AP-Singapore

    To reduce network latency, select the region nearest to you.

    Instance name

    rds-mysql

    Specify a name that will be easy to identify.

    DB engine version

    MySQL 5.7

    -

    Instance type

    Single

    A single instance is used in this example.

    To improve service reliability, select a primary/standby instance.

    Storage type

    Cloud SSD

    -

    AZ

    AZ1

    AZ1 is selected in this example.

    To improve service reliability, select the primary/standby instance type and deploy the primary and standby instances in different AZs.

    Instance class

    General-purpose 2 vCPUs | 8 GB

    -

To ensure a smooth data migration, you are advised to create an independent database account for connecting to the DRS task. In addition, you need to ensure that the account is granted required permissions.

  • Source database user
    1. Log in to the source database.
    2. Run the following statement to create database user usersrc:

      CREATE USER 'usersrc'@'%' IDENTIFIED BY 'password';

    3. Run the following statements to grant permissions to usersrc:

      GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'usersrc';

      GRANT SELECT, SHOW VIEW, EVENT, LOCK TABLES ON *.* TO 'usersrc';

  • Destination database user
    1. Connect to an RDS for MySQL instance through DAS.
    2. Run the following statement to create database user usertar. For details, see Creating a Database Account Through DAS.

      CREATE USER 'usertar'@'%' IDENTIFIED BY 'password';

    3. Run the following statement to grant permissions to usertar:

      GRANT SELECT, CREATE, ALTER, DROP, DELETE, INSERT, UPDATE, INDEX, EVENT, CREATE VIEW, CREATE ROUTINE, TRIGGER ON *.* TO 'usertar' WITH GRANT OPTION;

Before creating a migration task over a public network, you need to apply for an EIP and configure the firewall of your local data center so that the EIP can access the on-premises database.

  1. Create an EIP for the DRS migration task by referring to Assigning an EIP.
  2. Configure the firewall of the local data center.

    Add the EIP created in 1 to the whitelist of the source database to ensure that the source database can access EIP.

  3. Configure the IP address whitelist for the on-premises database.

    Add the DRS instance EIP to the whitelist of the on-premises database to allow the access from the DRS instance.

Step 1: Create a Migration Task

This step describes how to set parameters based on the example values in Preparations. For more information about real-time migration, see Migration Overview.

  1. Go to the Create Migration Task page.
  2. Configure basic information as follows:

    Figure 1 Basic information

    Parameter

    Example Value

    Description

    Region

    AP-Singapore

    The region where the current task is deployed.

    Project

    AP-Singapore

    The project corresponds to the current region.

    Task Name

    DRS-Migration

    The name of the migration task.

    Description

    Leave this parameter blank for now.

    Task description.

  3. Configure information about the replication instance.

    Figure 2 Replication instance details

    Parameter

    Example Value

    Description

    Data Flow

    To the Cloud

    The direction of the migration task. The options are To the cloud and Out of the cloud.

    • To the cloud: The destination database is a Huawei Cloud DB instance and data needs to be transferred to the cloud.
    • Out of the cloud: The source database is a Huawei Cloud DB instance and data needs to be transferred out of the cloud.

    Source DB Engine

    MySQL

    The DB engine type of the source database.

    Destination DB Engine

    MySQL

    The DB engine type of the destination database.

    Network Type

    Public network

    The network type of the migration task.

    • VPC: suitable for migrations between cloud databases of the same account in the same region and VPC.
    • Public network: suitable for migrations from on-premises databases or external cloud databases to destination databases.
    • VPN or Direct Connect: suitable for migrations from on-premises databases to cloud databases or between cloud databases across regions using a VPN, Direct Connect, Cloud Connect, VPCEP, or a VPC peering connection.

    Destination DB Instance

    rds-mysql

    Select a destination DB instance.

    The destination DB instance is rds-mysql in Databases.

    Replication Instance Subnet

    Default subnet

    The subnet where the migration task is.

    Migration Type

    Full+Incremental

    The available options are Full and Full+Incremental.

    • Full: This migration type is suitable for scenarios where services can be interrupted. If you are performing a full migration, do not perform operations on the source database during the migration, or data generated in the source database during the migration will not be synchronized to the destination database.
    • Full+Incremental: This migration type allows you to migrate data without interrupting services.

    Destination DB Instance Access

    Read-only

    During the migration, the destination DB instance can be set to read-only or read/write.

    • Read-only: During the migration, the destination database is read-only. After the migration is complete, it restores to the read/write status. This option ensures the integrity and improves the success rate of data migration.
    • Read/Write: During the migration, the destination database can be read and written.

    Enable Binlog Cleanup

    No

    Whether to enable the function of quickly clearing binlogs of the destination database.

    Specify EIP

    -

    Select an EIP for the DRS instance. In this example, it is the EIP created in Network.

  4. Select an AZ and an enterprise project.

    Figure 3 AZ and Enterprise Project

    Parameter

    Example Value

    Description

    AZ

    AZ1

    Select the AZ where you want to create the DRS task.

    Enterprise Project

    default

    If your account is associated with an enterprise project, select the project from the Enterprise Project drop-down list.

    For more details, see Enterprise Management User Guide.

    Tags

    Leave this parameter blank for now.

    Tags for the migration task. Adding tags helps you better identify and manage your tasks.

  5. Click Create Now.

    Wait for 5 to 10 minutes. If the message "Replication instance created successfully" is displayed, the DRS task is successfully created.

  6. On the Configure Source and Destination Databases page, specify source and destination database details and click Test Connection for both the source and destination databases to confirm they have been connected to the DRS instance.

    1. In the Source Database area, enter the source database details in Connection Accounts.
    2. Click Test Connection.

      If the message "Test successful" is displayed, the source database is connected.

    3. In the Destination Database area, enter the destination database details in Connection Accounts.
    4. Click Test Connection.

      If the message "Test successful" is displayed, the destination database is connected.

    5. Click Next.

  7. On the Set Task page, select the objects to be migrated and click Next.

    Figure 4 Migration Type

    Parameter

    Example Value

    Description

    Flow Control

    No

    Whether to set a maximum migration speed of the DRS task. This function is disabled by default. Flow Control is only used during the full migration phase.

    Migrate Incremental Accounts and Permissions

    No

    Whether to migrate incremental accounts and permissions during database migration.

    Migrate Account

    No

    Whether to migrate users in the source database.

    Filter DROP DATABASE

    No

    To reduce the risks involved in a migration, DRS allows you to filter out DROP operations.

    Migration Object

    All

    Select objects to be migrated. You can select All, Tables, or Databases as required.

  8. On the Check Task page, check the migration task.

    • If there are any items that require confirmation, view and confirm the details first before proceeding to the next step.
    • If any of the checks fail, review the cause and rectify the fault. After the fault is rectified, click Check Again.

    If the check success rate reaches 100%, the pre-check is successful.

  9. Click Next
  10. On the Compare Parameters page, compare and modify common and performance parameters.

    • If you do not want to compare parameters or the parameters of the source database are the same as those of the destination database, skip this step.
    • If the parameters of the source database are inconsistent with those of the destination database, you can manually change the values of the destination database parameters or click Use Source Database Value to make the parameter values of the source and destination database be the same.

  11. Click Next
  12. On the Confirm Task page, specify Start Time.

    Figure 5 Task startup settings

    Parameter

    Example Value

    Description

    Start Time

    Start upon task creation

    Set Start Time to Start upon task creation or Start at a specified time based on site requirements. The Start at a specified time option is recommended.

    Send Notifications

    Disable

    This parameter is optional. After enabled, select an SMN topic. If the task billing is about to start, the status, latency metric, or data of the migration task is abnormal, DRS will send you a notification.

    Stop Abnormal Tasks After

    14

    Any task in the Abnormal state that has run for longer than the period you set here (in days) will automatically stop.

  13. Confirm that the configured information is correct and click Submit to submit the task.
  14. After the migration task is submitted, go to the Online Migration Management page to check the task status.

    • If the task status is Starting, the task has been started.
    • By default, DRS retains a task in the Configuration state for three days. After three days, DRS automatically deletes background resources, but the task status remains unchanged. When you reconfigure the task, DRS applies for resources for the task again.

Step 2: Query Migration Progress

After the migration task is started, you can check the migration progress. DRS shows the migration progress using a progress bar, so you can track the migration progress in real time.

  1. On the Online Migration Management page, click the target migration task name in the Task Name/ID column.

    The Basic Information page is displayed.

  2. Choose Migration Progress to check the progress and details.

    • Progress Overview: When a full migration is complete, the progress of each item reaches 100%. The migration progress is displayed based on the number of migrated objects.
      Figure 6 Migration progress
    • Migration Details: If the values of Total Items and Migrated Items are the same, the object migration is complete.
      Figure 7 Migration progress details

    • Incremental migration delay: After the full migration is complete, you can check the delay of the incremental migration on the Migration Progress page.

      Delay refers to the delay from when the transaction was submitted to the source database to when it is synchronized to the destination database and executed.

      If the delay is 0, the source database is consistent with the destination database, and no new transactions need to be synchronized.

Step 3: Compare Migration Items

For a full+incremental migration task, when the full migration is complete and the incremental migration delay is 0, you can create a comparison task to check whether the data in the source database is consistent with that in the destination database.

  • Object-level comparison: It compares databases, indexes, tables, views, stored procedures and functions, and sorting rules of tables.
  • Data-level comparison: It checks the consistency of rows or values in the migration tables.

You can create an object-level comparison task to check the integrity of database objects.

  1. On the Online Migration Management page, click the target migration task name in the Task Name/ID column.

    The Basic Information page is displayed.

  2. Choose Migration Comparison.

    The Migration Comparison page is displayed.

  3. Click Object-Level Comparison.

    The Object-Level Comparison page is displayed.

  4. Click Compare.
  5. After 5 to 10 minutes, click to check the comparison result of each comparison item.

    If Consistent is displayed in the Result column, the object migration is complete.
    Figure 8 Object-Level Comparison

After the database object comparison is complete, you can create a data-level comparison task to check the number of rows or values of the migrated data.

  1. On the Online Migration Management page, click the target migration task name in the Task Name/ID column.

    The Basic Information page is displayed.

  2. Choose Migration Comparison.

    The Migration Comparison page is displayed.

  3. In the Before You Start pane, click Validate All Rows/Values.

    The Create Comparison Task page is displayed.

  4. Select a comparison policy and click OK to submit the comparison task.

    Figure 9 Creating a comparison task

    Parameter

    Example Value

    Description

    Comparison Type

    Row

    The available options are Row and Value.

    • Row comparison: It checks whether the number of rows in a source table is the same as that in the migrated table.
    • Value comparison: It checks whether the data in a source table is consistent with that in the migrated table.

    Comparison Time

    Start upon task creation

    The available options are Start upon task creation and Start at a specified time.

    Filter Data

    Disable

    Whether to set filtering criteria for comparison objects. After this function is enabled, objects can be compared based on the configured filtering criteria.

    Object

    Select All

    Select objects to be compared as needed.

  5. Go back to the Data-Level Comparison tab.
  6. Click to refresh the list. After the comparison task is complete, you can check the comparison result.

    If Consistent is displayed in the Result column, the object data in the source database is consistent with that in the destination database.
    Figure 10 Row comparison result

Stopping a Task

After confirming that the source and destination data is consistent, you can cut over workloads to the destination database. After workload cutover is successfully completed and applications are running properly, you can stop the migration task.

  1. On the Online Migration Management page, locate the task and click Stop in the Operation column.
  2. In the displayed dialog box, click Yes.