This topic describes how to create a PolarDB for MySQL cluster from an existing ApsaraDB RDS for MySQL instance by using data migration.

Prerequisites

Background information

PolarDB is a next-generation relational cloud database that is developed by Alibaba Cloud. The database service provides the following benefits:
  • Large storage capacity: up to 100 TB.
  • High performance: up to six times higher than MySQL.
  • Serverless storage: You do not need to purchase storage in advance. The storage can be automatically expanded and is charged based on usage.
  • Temporary upgrade: supports temporary specification upgrades to handle sudden workload fluctuations.

For more information, see Benefits.

The PolarDB for MySQL cluster contains the accounts, databases, IP whitelists, and required parameters of the source RDS instance. This is based on a typical scenario after a PolarDB for MySQL cluster is created from an existing ApsaraDB RDS for MySQL instance.

Precautions

  • The source RDS instance and the PolarDB cluster must be deployed in the same region.
  • The parameters of the source RDS instance cannot be modified during migration.
  • Before the migration, we recommend that you execute the following statement to check the minor version of the kernel for the RDS instance:
    show variables like '%rds_release_date%'

    If the minor version of the kernel is 20190130 or earlier, you must upgrade the minor version to the latest one before the migration. For more information, see Update the kernel version of an ApsaraDB RDS for MySQL instance.

Features

  • The data migration feature is free of charge.
  • No data loss occurs during the migration.
  • Supports incremental data migrations. This allows you to migrate data with a service downtime of less than 10 minutes.
  • Supports migration rollbacks. If a migration fails, it can be rolled back within 10 minutes.
  • Supports switch with endpoints interchange. You do not need to modify the configurations of your applications to reconnect to PolarDB.

Procedure

To migrate data from the RDS instance to the PolarDB for MySQL cluster, perform the following steps:

Migrate data from the source RDS instance

In this example, a PolarDB for MySQL cluster is created. The cluster stores the same data as the source RDS instance. Then, incremental data is dynamically synchronized from the source RDS instance to the PolarDB for MySQL cluster.
  1. Log on to the PolarDB console.
  2. On the top of the page, select the region where the target cluster is located.
  3. Click Create Cluster.
  4. On the buy page that appears, click the Subscription or Pay-As-You-Go tab.
  5. Set the parameters listed in the following table.
    Parameter Description
    Region Select the region where the ApsaraDB RDS for MySQL instance is deployed.
    Note The destination PolarDB for MySQL cluster must be also deployed in this region.
    Create Type Select Migration from RDS. PolarDB uses this method to clone a cluster from the source RDS instance. Data synchronization is maintained between the RDS instance and the PolarDB cluster. By default, the binary logging feature is enabled for the PolarDB cluster.
    RDS Engine Type The engine type of the source RDS instance. This parameter cannot be modified.
    RDS Engine Version The engine version of the source RDS instance. This parameter cannot be modified.
    Source RDS instance Select an available RDS instance from the drop-down list. Read-only RDS instances are not listed.
    Primary Availability Zone

    The zone of the cluster. Each zone is an independent geographical location within a region. The zones that are deployed in the same region are similar.

    You can deploy your PolarDB for MySQL cluster and the Elastic Compute Service (ECS) instance in the same zone or in different zones.

    Network Type The network type of the PolarDB for MySQL cluster. This parameter cannot be modified.
    VPC

    VSwitch

    The VPC network and VSwitch to which the PolarDB for MySQL cluster is connected. Make sure that the PolarDB for MySQL cluster and ECS instance are deployed in the same VPC network. Otherwise, the cluster and the ECS instance cannot communicate with each other over an internal network and cannot achieve optimal performance.
    Compatibility The database engine of the PolarDB for MySQL cluster. This parameter cannot be modified.
    Node Specification Select a node specification for the PolarDB for MySQL cluster based on your workload requirements. We recommend that you select a specification that is the same or higher than the specification of the source RDS instance. All nodes in the PolarDB for MySQL cluster are dedicated nodes with stable performance. For more information, see Specifications and pricing.
    Nodes The number of nodes in the new cluster. This parameter cannot be modified. The system automatically creates a read-only node with the same specification as that of the primary node.
    Storage Cost You do not need to set this parameter. Storage fees are charged based on the usage on an hourly basis. For more information, see Specifications and pricing.
  6. Set the Purchase Plan parameter if you want to create a subscription cluster, and click Buy Now on the right side of the page.
  7. Confirm the order information, read and accept the Agreement of Service, and then click Pay.
  8. Log on to the PolarDB console and check the status of the new PolarDB for MySQL cluster.
    Note
    • After the cluster is created, the system starts to migrate data from the RDS instance to the cluster. You must click Complete Migration in the PolarDB console within seven days after the migration starts. The migration task is automatically terminated after seven days.
    • You can also cancel the migration. For more information about the impacts of canceling a migration task, see FAQ.

Perform a reverse migration

You can perform a reverse migration to synchronize data from the PolarDB cluster to the RDS instance if the following conditions are met:

  1. Log on to the PolarDB console.
  2. Find the destination cluster and click the cluster ID to go to the Overview page.
  3. On the Overview page, click Switch. In the message that appears, click OK. This allows you to reverse the migration and synchronize incremental data from the PolarDB for MySQL cluster to the RDS instance. After the synchronization is completed, the source RDS instance is switched to the read-only mode and the PolarDB for MySQL cluster is switched to the read/write mode.Perform a reverse migration
    Note In most cases, it takes less than five minutes for the system to complete the reverse migration process.
  4. In the Start Switching dialog box, select Switch with Endpoints (Connection Changes Not Required) or Switch without Endpoints (Connection Changes Required).
    Start the reverse migration
    If you select Switch with Endpoints (Connection Changes Not Required), perform the following steps:
    1. After you select Switch with Endpoints (Connection Changes Not Required), the system automatically interchanges the endpoints between the RDS instance and the PolarDB for MySQL cluster. You do not need to modify the configurations of your applications to reconnect to the PolarDB for MySQL cluster. The following figure shows the rules for endpoints interchange between the RDS instance and the PolarDB for MySQL cluster.
      Rules for endpoints interchange
      Notice
      • If you select Switch with Endpoints Interchange, only the domain names of the RDS instance and the PolarDB for MySQL cluster are interchanged. Other configurations such as the VSwitches and VIPs are not interchanged.
      • If you select Switch with Endpoints Interchange, the port numbers are not interchanged. Make sure that the port number of the RDS instance is the same as that of the PolarDB for MySQL cluster. If not, you can modify either of the port numbers. For more information, see View and change the internal and public endpoints and port numbers of an ApsaraDB RDS for MySQL instance and Modify the endpoint and port.
      • After domain names are interchanged, a Domain Name System (DNS) cache issue may occur. You may fail to connect to the database before the DNS cache expires. To fix this issue, we recommend that you refresh the DNS cache.
      • If you want to use Data Management Service (DMS) to log on to the PolarDB database, you must use the latest version of DMS and log on to the database with the cluster ID.
    2. Click OK.
      Note After the reverse migration, if data errors are found, you can roll back the database to the status that exists before the migration. For more information, see Roll back the migration.
    If you select Switch without Endpoints (Connection Changes Required), perform the following steps:
    1. After you select Switch without Endpoints (Connection Changes Required) and complete the reverse migration, you must change the database endpoint in your applications at the earliest opportunity.
    2. Click OK.
    3. Refresh the page. After PolarDB Read/Write Status changes to Read and Write, change the database endpoint in your applications at the earliest opportunity.
      Refresh
      Note After the switchover, if data errors are found, you can roll back the database to the status that exists before the migration. For more information, see Roll back the migration.

Complete the migration

After you complete the tasks described in the Migrate data from the source RDS instance section, you must change the database endpoint in your applications, and click Complete Migration in the PolarDB console within seven days.
Warning This operation stops data synchronization between the RDS instance and the PolarDB cluster, and the rollback feature becomes unavailable. We recommend that you test the PolarDB cluster to confirm that the cluster runs as expected before you click Complete Migration.
  1. Log on to the PolarDB console.
  2. Find the destination cluster and click the cluster ID to go to the Overview page.
  3. On the Overview page, click Complete Migration. In the message that appears, click OK.Complete the migrationConfirm migration completion
    Note
    • After you click OK, the system stops data synchronization within about two minutes. During this process, the Complete Migration button is still available. Do not click it again.
    • You can specify whether to disable the binary logging feature for the PolarDB for MySQL cluster. If this feature is disabled, the write performance can be slightly improved. However, you must restart the PolarDB for MySQL cluster.
    • If the source RDS instance is no longer required, you can release the instance . For more information, see Release or unsubscribe from an ApsaraDB RDS for MySQL instance.

Roll back the migration

Before you complete a migration, if data errors are found, you can roll back the migration. After the rollback operation is completed, the source RDS instance is switched to the read/write mode, and the PolarDB for MySQL cluster is switched to the read-only mode. The system synchronizes data from the RDS instance to the PolarDB for MySQL cluster.

  1. Log on to the PolarDB console.
  2. Find the target cluster and click the cluster ID to go to the Overview page.
  3. On the Overview page, click Rollback.Roll back the migration
  4. In the Switch Back dialog box, select Switch Back with Endpoints (Connection Changes Not Required) or Switch Back without Endpoints (Connection Changes Required).
    1
    If you select Switch Back with Endpoints (Connection Changes Not Required), perform the following steps:
    1. After you select Switch Back with Endpoints (Connection Changes Not Required), the system automatically interchanges the endpoints between the RDS instance and the PolarDB for MySQL cluster. You do not need to modify the configurations of your applications to reconnect to the PolarDB for MySQL cluster.
      Notice
      • If you select Switch with Endpoints Interchange, only the domain names of ApsaraDB for RDS and PolarDB are interchanged. Other configurations such as the VSwitches and VIPs are not interchanged.
      • If you select Switch with Endpoints Interchange, the port numbers are not interchanged. Make sure that the port number of the RDS instance is the same as that of the PolarDB for MySQL cluster. If not, you can modify either of the port numbers. For more information, see View and change the internal and public endpoints and port numbers of an ApsaraDB RDS for MySQL instance and Modify the endpoint and port.
      • After domain names are interchanged, a DNS cache issue may occur. You may fail to connect to the database before the DNS cache expires. To fix this issue, we recommend that you refresh the DNS cache.
    2. Click OK.
      Note After you click OK, the system synchronizes data from the source RDS instance to the PolarDB for MySQL cluster. After the rollback operation is completed, the source RDS instance is switched to the read/write mode and the PolarDB for MySQL cluster is switched to the read-only mode.
    If you select Switch Back without Endpoints (Connection Changes Required), perform the following steps:
    1. After you select Switch Back without Endpoints (Connection Changes Required) and complete the reverse migration, you must change the database endpoint in your applications at the earliest opportunity.
    2. Click OK.
      Note After you click OK, the system synchronizes data from the source RDS instance to the PolarDB for MySQL cluster. After the rollback operation is completed, the source RDS instance is switched to the read/write mode and the PolarDB for MySQL cluster is switched to the read-only mode.
    3. Refresh the page. After Source RDS Read/Write Status changes to Read and Write, change the database endpoint to that of the RDS instance in your applications at the earliest opportunity.

FAQ

  • Q: Is the source RDS instance affected when data is migrated from the RDS instance?

    A: No, the source RDS instance can run as expected.

  • Q: Does smooth migration affect my workloads running on the connected databases?

    A: Smooth migration ensures zero data loss during the migration. The service downtime is less than 10 minutes. You can roll back the migration if necessary.

  • Q: What happens if I cancel the migration?

    A: After the migration is canceled, you can modify the parameters of the source RDS instance. The PolarDB cluster is switched to the read/write mode, and the data is not released. If you manually cancel the migration, you can specify whether to disable the binary logging feature for the PolarDB cluster. Binary logging is not disabled if the migration is automatically canceled.

Related operations

Operation Description
CreateDBCluster Creates a PolarDB cluster.
Note To create a cluster by cloning an existing RDS instance with data migration, set the CreationOption parameter to MigrationFromRDS.
DescribeDBClusterMigration Queries the status of data migration for a PolarDB cluster.
ModifyDBClusterMigration Performs a reverse migration to synchronize cluster data to the source RDS instance, or rolls back the migration.
CloseDBClusterMigration Cancels or completes the migration for a PolarDB cluster.