This topic describes the procedure for upgrading PolarDB for MySQL clusters.
Preparation: Check whether the service-linked role for PolarDB is created
Before you perform an upgrade, make sure that the service-linked role for PolarDB has been created and that Data Transmission Service (DTS) has been authorized to access cloud resources. For more information, see Authorize DTS to access Alibaba Cloud resources.
The following section describes how to check whether the service-linked role for PolarDB is created.
Log on to the RAM console.
Check whether the service-linked role named AliyunServiceRoleForPolarDB as shown in the following figure already exists in the list.
If so, skip this section and perform the operations in Step 1: Create a new PolarDB for MySQL cluster.
If not, perform the subsequent steps in this section.
On the page that appears, click Create Role.
In the Create Role panel, select Alibaba Cloud Service for Select Trusted Entity and click Next.
In the Configure Role step, set Role Type to Service Linked Role and Select Service to ApsaraDB for PolarDB.
Click OK. In the Roles list, confirm that the role is created.
Step 1: Create a new PolarDB cluster
In this step, create a new cluster that contains the same data as your existing PolarDB for MySQL cluster. The incremental data of the old PolarDB for MySQL cluster is synchronized to the new cluster in real time.
Log on to the PolarDB console.
Go to the cluster buy page by using one of the following methods:
On the Clusters page, click Create Cluster.
On the Clusters page, click the ID of the cluster that you want to upgrade. In the left-side navigation pane of the page that appears, choose Settings and Management > Version Management. On the Major Version Upgrade tab, click Upgrade by Migration.
On the page that appears, set Product Type to Subscription or Pay-As-You-Go.
Subscription: When you create a cluster, you must pay for the compute nodes. You are charged for the use of storage resources and the costs are deducted from your account balance on an hourly basis.
Pay-as-you-go: An upfront payment is not required. You are charged for the compute nodes and the amount of storage that is consumed by your data. These costs are deducted from your account balance on an hourly basis.
NoteFor more information about the subscription and pay-as-you-go billing methods, see Compute node billing methods.
Configure the parameters on the page based on the following table.
NoteFor information about the parameters that are not described in the following table, see Purchase a pay-as-you-go cluster or Purchase a subscription cluster.
Parameter
Description
Creation Method
Select Upgrade/Migrate from PolarDB.
Region and Zone
The region of the source PolarDB for MySQL cluster.
Source PolarDB Engine
The engine of the source PolarDB cluster. The value is set to MySQL and cannot be changed.
Source PolarDB Version
The engine version of the source PolarDB for MySQL cluster. Valid values: 5.6, 5.7, and 8.0.
Source PolarDB Cluster
The ID of the source cluster.
Compatibility
The engine version of the destination PolarDB cluster.
If you want to perform a version upgrade, you can choose the same or different version as that of the source PolarDB cluster.
If you want to perform an edition upgrade, you can only choose MySQL 8.0.
NoteEdition
The edition of the destination PolarDB cluster.
If you want to perform a version upgrade, set the parameter to Cluster.
If you want to perform an edition upgrade, set the parameter to Multi-master Cluster (Database/Table).
NoteNode Specification
The specifications of the destination cluster. We recommend that you select a specification that is the same as the source PolarDB for MySQL cluster or higher.
For more information about the node specifications of the PolarDB cluster, see Specifications of compute nodes.
If you want to a subscription cluster, configure Purchase Plan and Number and click Buy Now.
On the Confirm Order page, confirm your order information. Read the terms of service, select the check box, and then click Pay (if the billing method is subscription) or Activate Now (if the billing method is pay-as-you-go).
If the billing method of the cluster is subscription, the Purchase page appears. Confirm the order and the payment method, and click Subscribe.
NoteAfter you complete the payment, wait 10 to 15 minutes. Then, you can view the newly created cluster on the Clusters page.
If some nodes in the cluster are still in the Creating state, the cluster is still being created and is unavailable. The cluster is only available when the cluster is in the Running state.
Make sure that you have selected the region where the cluster is deployed. Otherwise, you cannot view the cluster.
Click the cluster ID to go to the cluster details page.
In the Upgrade section of the page, check the value of the Replication Delay parameter. If the value is smaller than 60 seconds, perform the operations in Step 2: Switch over to the new cluster.
NoteWhen the cluster is created, DTS starts synchronizing data from the old cluster. You need to complete the upgrade within 30 days. The upgrade fails after 30 days.
You can also click Cancel Upgrade. For information about the impact of cancelling an upgrade, see FAQ of major version upgrades.
If the status is Pre-check Failed, perform troubleshooting based on the error message.
For example, if a trigger has been created in the source cluster, the pre-check fails.
If you are sure that the trigger will not cause data inconsistency between the old and new databases, you can click Continue Upgrade to ignore the issue.
If data inconsistency may occur, you can delete the trigger in the PolarDB cluster and click Continue. Alternatively, you can click Cancel Upgrade and manually create a migration task in the DTS console. For more information, see Configure a data synchronization task for a source database that contains a trigger.
During an edition upgrade, the primary node whose ID is 1 is used for processing write requests by default. To avoid errors during data synchronization, we recommend that you do not change the primary node.
Step 2: Switch over to the new cluster
Before you perform this step, make sure that the replication latency of the new cluster is shorter than 60 seconds.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the Upgrade section of the cluster details page, click Upgrade Switchover.
NoteThe switchover is completed in about 5 minutes.
After the switchover, the old cluster becomes read-only, while the new cluster processes both read and write requests. DTS will also change the data replication direction. Incremental data will be synchronized from the new cluster to the old cluster.
In the dialog box that appears, 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 automatically interchanges the connection endpoints of old and new PolarDB clusters. You do not need to change the configurations of your applications for the applications to connect to the new PolarDB cluster.
ImportantBefore you select this option, make sure that you are familiar with the items in the "Precautions" section of the Overview of major version upgrades topic.
If the cluster that you want to upgrade is the source or destination of a task created in the Data Transmission Service (DTS) console, you must recreate the task after the upgrade. Such tasks include data synchronization tasks, data migration tasks, and change tracking tasks. For more information about how to create a DTS task, see What is Data Transmission Service?.
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.
If data errors occur after the switchover, you can roll back the switchover. For more information, see the "(Optional) Roll back the upgrade" section of this topic.
After an edition upgrade is complete, we recommend that you do not modify the primary nodes of the new Multi-master Cluster Edition cluster. Otherwise, errors may occur to data synchronization.
Step 3: Complete the upgrade
After you complete the operations in Step 1: Create a new PolarDB for MySQL cluster, you need to complete the upgrade within 30 days.
Before you click Complete Upgrade, make sure that data migration is complete, and data synchronization is no longer needed.
After you complete the upgrade, data is no longer synchronized from the new cluster to the old cluster, and you can no longer roll back the upgrade. We recommend that you use the new cluster for some time, and complete the upgrade after you are sure that the cluster runs as normal.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the PolarDB Upgrade section of the cluster details page of the new cluster, click Complete Upgrade.
In the dialog box that appears, specify whether you want to disable binary logging for the new cluster. Then, click OK.
NoteAfter you click OK, the system stops data synchronization within about 2 minutes. During this process, the upgrade status of the cluster is Disabling Synchronization.
If you selected Disable Binary Logging for Destination Instance, the cluster is restarted for the configuration to take effect.
If the old cluster is no longer needed, you can release it. For information about how to release clusters, see Release a cluster.
If you are performing an edition upgrade, after you click OK in the Complete Upgrade dialog box, the system randomly assigns primary nodes for processing write requests.
(Optional) View details of data synchronization tasks
If an error occurs during an upgrade, you can go to the DTS synchronization task details page for more information.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the PolarDB Upgrade section of the cluster details page, click the value of the DTS Data Synchronization Task parameter to go to the Data Synchronization Tasks page of the DTS console.
Click the ID of the synchronization task to go to the task details page.
During an upgrade, if you want to change the objects of synchronization, you can click Reselect Objects on the task details page. For example, the old cluster may have new databases that also need to be included for the synchronization task.
(Optional) Roll back the upgrade
If an error occurs before you complete the upgrade, you can roll the cluster back to before the upgrade. After a rollback, the old cluster will handle both read and write requests, the new cluster becomes read-only, and data is synchronized from the old cluster to the new cluster.
Log on to the PolarDB console.
Find the cluster and click the cluster ID.
In the PolarDB Upgrade section of the cluster details page of the new cluster, click Upgrade Rollback.
In the dialog box that appears, select Switch Back with Endpoints (Connection Changes Not Required) or Switch Back without Endpoints (Connection Changes Required).
Switch Back with Endpoints (Connection Changes Not Required):
The system automatically interchanges the endpoints of the old and new clusters. You do not need to change the configurations of your applications for the applications to connect to the old cluster.
Then, click OK. In the message that appears, click Confirm.
After the rollback, the old cluster processes both read and write requests, while the new cluster becomes read-only. DTS also changes the data replication direction. Incremental data is synchronized from the old cluster to the new cluster.
NoteWhen you roll back an edition upgrade, you can select the endpoints for the rollback.
Switch Back without Endpoints (Connection Changes Required):
After the rollback, you need to change the database endpoint in your applications at the earliest opportunity.
After you click OK, the old cluster processes both read and write requests, while the new cluster becomes read-only. DTS will also change the data replication direction. Incremental data will be synchronized from the old cluster to the new cluster.
Refresh the page. If the Read/Write Status of Source PolarDB parameter value changes to Read and Write, change the database endpoint in your applications at the earliest opportunity.