This topic describes how to upgrade an ApsaraDB RDS for MySQL instance to a PolarDB cluster.
Preparations
Check whether the service-linked role for PolarDB is created (required only for logical migration)
If you have completed the migration evaluation and confirmed that no related issues exist, you can skip this check. For more information about migration evaluation, see Migration evaluation.
Before you use the logical migration (data synchronization over DTS) method to perform an upgrade, check whether the service-linked role for PolarDB has been created and whether Data Transmission Service (DTS) has been authorized to access Alibaba Cloud resources. For more information, see Authorize DTS to access Alibaba Cloud resources. To check whether the service-linked role for PolarDB has been created, perform the following steps:
Log on to the Roles page in the Resource Access Management (RAM) console.
Check whether a service-linked role named AliyunServiceRoleForPolarDB already exists in the list as shown in the following figure.
If the service-linked role exists in the list, perform the operations in Step 1: Migrate data from the source ApsaraDB RDS for MySQL instance. If the service-linked role does not exist in the list, you must create the role.
In the upper-left corner, click Create Role.
In the Select Role Type step of the Create Role panel, select Alibaba Cloud Service and click Next.
In the Configure Role step, set Role Type to Service Linked Role and select ApsaraDB for POLARDB from the Select Service drop-down list.
Click OK. Return back to the role list to confirm that the role is created.
Remove extra system accounts from the source ApsaraDB RDS instance (required only for logical migration)
If you have completed migration evaluation and confirmed that no related issues exist, you can skip this check. For more information about migration evaluation, see Migration evaluation.
To ensure compatibility between ApsaraDB RDS for MySQL and PolarDB in terms of the system account structure and to prevent the system accounts of the destination PolarDB cluster from being overwritten during migration, make sure that the root and aliyun_root accounts do not exist in the source ApsaraDB for RDS instance at the same time. Before you initiate the migration process, we recommend that you remove extra system accounts from the source ApsaraDB for RDS instance.
The following table lists the correct system account name for each version of ApsaraDB RDS for MySQL.
ApsaraDB RDS for MySQL version | Correct system account name |
RDS MySQL 5.6 | root |
RDS MySQL 5.7 | aliyun_root |
RDS MySQL 8.0 | aliyun_root |
Apart from the corresponding system account for each version mentioned in the preceding table, all other system accounts must be removed.
Extra system accounts may have been created by users or inherited from the source version during a version upgrade. In some scenarios, specific accounts may not be visible in the console.
The following example shows how to remove extra system accounts from an ApsaraDB RDS for MySQL 5.6 instance:
Use a privileged account to connect to the database.
Find all root and aliyun_root system accounts.
select * from mysql.user where user in ('root', 'aliyun_root');
Remove extra system accounts. The correct system account name of ApsaraDB RDS for MySQL 5.6 is root. Therefore, you must remove the aliyun_root account.
delete from mysql.user where user = 'aliyun_root' limit n;
Step 1: Migrate data from the source ApsaraDB RDS for PostgreSQL instance
In this step, create a PolarDB cluster that contains the same data as the source ApsaraDB RDS for MySQL instance. Incremental data is synchronized from the source ApsaraDB RDS for MySQL instance to the PolarDB cluster in real time.
Before you migrate data, we recommend that you complete the migration evaluation. For more information about migration evaluation, see Migration evaluation.
Log on to the PolarDB console and click Create Cluster to go to the PolarDB buy page.
Set Billing Method to Subscription, Pay-as-you-go, or Serverless.
Subscription: You must pay upfront for compute nodes when you create a cluster. Storage is billed based on actual hourly usage, and fees are deducted from your account on an hourly basis.
Pay-as-you-go: An upfront payment is not required. You are charged fees for the compute nodes and the amount of storage that is consumed by your data. These fees are deducted from your account on an hourly basis.
Serverless: An upfront payment is not required. Resources such as compute nodes, storage space, and PolarProxy dynamically scales based on the actual demand. You are charged fees based on the actual usage of these scaled resources.
Configure the parameters. The following table describes the parameters.
NoteFor information about the parameters that are not described in the following table, see Purchase clusters.
State
Description
Creation Method
Select Migrate from ApsaraDB RDS.
NoteThe PolarDB cluster is in the read-only mode before the migration and switchover. By default, binary logging is enabled for the cluster.
Region
The region where the source ApsaraDB RDS for MySQL instance is deployed.
NoteThe destination PolarDB cluster must be also deployed in this region.
RDS Engine Type
The database engine of the source ApsaraDB RDS instance. The default value of this parameter is MySQL and cannot be changed.
RDS Engine Version
The database engine version of the source ApsaraDB RDS for MySQL instance. Valid values: 5.6, 5.7, and 8.0.
Source RDS Instance
The source ApsaraDB RDS for MySQL instance. The available source ApsaraDB RDS for MySQL instances exclude read-only instances.
Database Engine
The database engine version of the destination PolarDB cluster. You can select the same version as the source ApsaraDB RDS for MySQL instance or a different version.
Node Specification
The node specifications of the cluster. You can specify node specifications based on your business requirements. We recommend that you select specifications that are the same as or higher than the specifications of the source ApsaraDB RDS for MySQL instance. For more information about PolarDB node specifications, see Compute node specifications of PolarDB for MySQL Enterprise Edition.
Storage Engine
PolarDB supports the following storage engines: InnoDB and InnoDB & X-Engine.
InnoDB: InnoDB storage engine.
InnoDB & X-Engine: deploys both InnoDB and X-Engine. If you select this option, you can specify the X-Engine memory usage ratio. For more information, see X-Engine Edition.
In the upper-right corner of the page, check the cluster configuration and configure the Duration, Quantity, and Auto-renewal parameters. The Duration parameter is available only for subscription clusters.
Read and select terms of service. Click Confirm Order.
On the Purchase page, confirm the order and the payment method, and click Purchase.
NoteAfter you complete the payment, wait for 10 to 15 minutes. Then, you can view the new cluster on the Clusters page.
If specific nodes in the cluster are in the Creating state, the cluster is still being created and is unavailable. The cluster is available only when the cluster is in the Running state.
Make sure that you select the region where the cluster is deployed. Otherwise, you cannot view the cluster.
After the cluster is created, log on to the PolarDB console and click the cluster ID to go to the Basic Information page of the cluster.
In the RDS Migration section of the Basic Information page, check the Replication Latency value of the destination PolarDB cluster. If the value is smaller than 60 seconds, you can perform the operations in Step 2: Switch over services.
NoteAfter the cluster is created, the system starts to migrate data from the ApsaraDB RDS for MySQL instance to the cluster. You must perform the operations in Step 4: Complete the migration within 30 days after the cluster is created. Otherwise, the migration task is automatically terminated after 30 days.
If the logical migration method is used and the Status value displayed in the RDS Migration section is Precheck Failed after the PolarDB cluster is created, follow the instructions in the error message to troubleshoot the issue.
For example, if a trigger is created in the source ApsaraDB RDS for MySQL instance, the precheck fails and the "The RDS instance has a trigger." error message is reported. You can delete the trigger and then click Continue. Alternatively, you can click Cancel and then manually create a data synchronization task in the DTS console. For more information, see Configure a data synchronization task for a source database that contains a trigger.
You can also click Cancel in this step. For more information, see FAQ.
Step 2: Switch over services
If the Replication Latency value of the destination PolarDB cluster is smaller than 60 seconds, you can perform the switchover operation.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the RDS Migration section of the Basic Information page, click Switch Over Business.
NoteIn most cases, it requires less than 5 minutes for the system to compete the switchover.
After the switchover, the read/write states of the source ApsaraDB RDS for MySQL instance and the destination PolarDB cluster are interchanged. The read/write state of the source ApsaraDB RDS for MySQL instance is changed to Read Only, and the read/write state of the PolarDB cluster is changed to Read and Write. The replication direction is also changed. In this case, incremental data is synchronized from the PolarDB cluster to the ApsaraDB RDS for MySQL instance.
To continue the migration, click OK. To check non-upgrade Data Transmission Service (DTS) tasks, click Cancel.
In the Start Switchover dialog box, select Switch with Endpoints (Connection Changes Not Required) or Switch without Endpoints (Connection Changes Required).
Switch with Endpoints (Connection Changes Not Required)
If you select Switch with Endpoints (Connection Changes Not Required), the system interchanges the endpoints between the ApsaraDB RDS for MySQL instance and the PolarDB cluster. You do not need to modify the configurations of your application to connect to the PolarDB cluster.
ImportantBefore you select Switch with Endpoints (Connection Changes Not Required), make sure that you read notes for switchover with endpoints.
If PolarDB cluster to be upgraded is the source or destination of an existing DTS task, you must change the source or destination cluster of the DTS task to the upgraded PolarDB cluster after the cluster is upgraded. Such tasks include data synchronization tasks, data migration tasks, and change tracking tasks. For more information, see Modify the objects to be synchronized.
Then, click OK. In the message that appears, click Confirm.
Switch without Endpoints (Connection Changes Required):
Select Switch without Endpoints (Connection Changes Required) in the dialog box.
Then, click OK. In the message that appears, click Confirm.
Refresh the page. If Read/Write Status of Destination PolarDB changes to Read and Write, change the database endpoint in your applications at the earliest opportunity.
NoteIf data errors occur after the migration is complete, you can roll back the migration. This allows you to restore the database and data to the original state before the migration is performed. For more information, see Roll back the migration. You can then select Cancel Migration to restore the cluster status before the migration.
Step 3: (Optional) Switch over source instance DTS tasks
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the RDS Migration section of the Basic Information page, click Business DTS Task Database Endpoint Switchover.
In the Business DTS Task Database Endpoint Switchover dialog box, select Source Instance DTS Task (Forward Switchover) or Destination Instance DTS Task (Switchover Rollback).
ImportantBefore the switchover, check the states of DTS synchronization tasks of the source and destination instances. For more information, see DescribeDtsJobDetail.
If you select Source Instance DTS Task (Forward Switchover), perform the following steps:
Select the DTS task of the instance.
Click Commit Forward Switchover.
If you select Destination Instance DTS Task (Switchover Rollback), perform the following steps:
Select the DTS task of the instance.
Click Commit Switchover Rollback.
The Source Instance DTS Task (Forward Switchover) option can switch over the DTS task from the source instance to the destination instance to complete the DTS task before the migration.
The Destination Instance DTS Task (Switchover Rollback) option can switch over the DTS task from the destination instance to the source instance to cancel the migration.
Step 4: Complete the migration
After you complete the operations described in the Step 1: Migrate data from the source ApsaraDB RDS for MySQL instance section, you must click Complete Migration within 30 days.
Before you complete the migration by clicking Complete Migration, make sure that data migration is complete and that the synchronization task is no longer used. This operation terminates data replication from the source ApsaraDB RDS for MySQL instance to the PolarDB cluster if physical migration is used, and deletes the data synchronization task if logical migration is used.
This operation interrupts data synchronization between the PolarDB cluster and the ApsaraDB RDS for MySQL instance. Therefore, the Cancel Migration option is no longer available. We recommend that you perform this operation after you use the PolarDB cluster for a period of time and make sure that the cluster is normal.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the RDS Migration section of the Basic Information page, click Complete Migration. In the dialog box that appears, click OK.
NoteAfter you click OK, the system stops data synchronization within approximately 2 minutes. During this process, the migration status is Disable Synchronization. Wait until the migration is complete.
In the Complete Migration dialog box, you can specify whether to disable the binary logging feature for the PolarDB cluster. If you disable the binary logging feature, write performance can be slightly improved. The PolarDB cluster automatically restarts after you disable the binary logging feature for the new configuration to take effect.
If you no longer need the source ApsaraDB RDS instance, you can release or unsubscribe from the instance. For more information, see the "(Optional) Release or unsubscribe from an ApsaraDB RDS instance" section of this topic.
If you want to perform operations such as renewal or configuration changes on the source ApsaraDB RDS instance, click Complete Migration first.
(Optional) Release or unsubscribe from an ApsaraDB RDS instance
After data is migrated from the source ApsaraDB RDS instance to the PolarDB cluster, you can release or unsubscribe from the instance if services run on the cluster as expected and the instance is no longer required.
You can unsubscribe from ApsaraDB RDS instances that use the subscription billing method. For more information, see Unsubscribe from a subscription primary RDS instance.
Release ApsaraDB RDS instances that use the pay-as-you-go billing method at the earliest opportunity to save RDS resources. For more information, see Release or unsubscribe from an ApsaraDB RDS for MySQL instance.
(Optional) View the details of a data synchronization task (available only for logical migration)
During the process of upgrade by using logical migration, if you encounter migration errors (such as a precheck failure) or other exceptions (such as high replication delay), you can go to the details page of the data synchronization task to view specific information about the task.
Log on to the PolarDB console.
Find the target cluster and click its ID.
In the RDS Migration section of the Basic Information page, click the name of DTS Data Synchronization Task to go to the data synchronization task list in the DTS console.
Find the data synchronization task. You can view precheck failure details, data synchronization task details, and data synchronization task logs.
During the migration process, if you want to adjust the synchronization objects of the synchronization task, you can click Reselect Objects. For example, the source ApsaraDB RDS for MySQL instance may have new databases that also need to be included in the synchronization task.