All Products
Search
Document Center

PolarDB:Procedure

Last Updated:Oct 20, 2023

This topic describes how to upgrade 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 is created and that Data Transmission Service (DTS) has been authorized to access Alibaba 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.

  1. Log on to the Resource Access Management (RAM) console.

  2. Check whether the service-linked role named AliyunServiceRoleForPolarDB already exists in the list, as shown in the following figure.AliyunServiceRoleForPolarDB

    • If the service-linked role exists in the list, skip this section and perform the operations in Step 1: Create a PolarDB cluster.

    • If the service-linked role does not exist in the list, continue with the following steps.

  3. On the Roles page, click Create Role.

  4. In the Create Role panel, set Select Trusted Entity to Alibaba Cloud Service and then click Next.创建角色

  5. In the Configure Role step, set Role Type to Service Linked Role and Select Service to ApsaraDB for PolarDB.配置角色

  6. Click OK. In the Roles list, confirm that the role is created.

Remove redundant system accounts from the source PolarDB for MySQL cluster

To prevent the system account of the destination PolarDB for MySQL cluster from being overwritten during migration, make sure that the root and aliyun_root accounts do not exist in the source PolarDB for MySQL cluster at the same time. Before you initiate the migration process, we recommend that you remove redundant system accounts from the source PolarDB for MySQL cluster.

The following table lists the correct system account name for each version of PolarDB for MySQL.

PolarDB for MySQL version

Correct system account name

PolarDB for MySQL 5.6

root

PolarDB for MySQL 5.7

aliyun_root

PolarDB for MySQL 8.0

root

Apart from the corresponding system account for each version mentioned in the preceding table, all other system accounts must be removed.

Note

These accounts may be created by users or automatically created by the system during version upgrades. Some accounts may be invisible in the PolarDB console in certain scenarios.

The following example shows how to remove redundant system accounts from a PolarDB for MySQL 5.6 cluster:

  1. Use a privileged account to connect to the cluster. For more information, see Connect to a cluster.

  2. Find all root and aliyun_root system accounts.

    select * from mysql.user where user in ('root', 'aliyun_root');
  3. Remove redundant system accounts. The correct system account of the PolarDB for MySQL 5.6 cluster is root. Therefore, you must remove the aliyun_root account.

    delete from mysql.user where user = 'aliyun_root' limit n; 

(Optional) Perform intelligent stress testing

Before you upgrade the PolarDB for MySQL version, you can use the intelligent stress testing feature to simulate your business traffic running in a PolarDB cluster of a specified version. This helps you achieve the following goals:

  • Check whether your cluster needs to be scaled up to effectively cope with business traffic spikes.

  • Analyze performance differences in SQL execution between the source and destination versions of the PolarDB cluster.

For more information about how to perform an intelligent stress testing task, see Intelligent stress testing.

Step 1: Create a PolarDB cluster

In this step, create a cluster that contains the same data as your source PolarDB for MySQL cluster. The incremental data of the source PolarDB for MySQL cluster is synchronized to the new cluster in real time.

  1. Log on to the PolarDB console.

  2. 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.

  3. 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 fees for the use of storage resources and the fees are deducted from your account balance 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 balance on an hourly basis.

      Note

      For more information about the subscription and pay-as-you-go billing methods, see Overview.

  4. Configure the parameters described in the following table.

    Note

    For 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 PolarDB for MySQL cluster.

    Compatibility

    The engine version of the destination PolarDB cluster.

      Note
      • 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.

    Edition

    The edition of the destination PolarDB cluster.

      Note
      • 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).

    Node 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 Compute node specifications of PolarDB for MySQL Enterprise Edition.

  5. If you want to purchase a subscription cluster, configure Purchase Plan and Number and then click Buy Now.

  6. 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).

  7. If the billing method of the cluster is subscription, the Purchase page appears. Confirm the order and the payment method, and click Subscribe.

    Note
    • After you complete the payment, wait for 10 to 15 minutes. Then, you can view the new 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 in which the cluster is deployed. Otherwise, you cannot view the cluster.

  8. Click the cluster ID to go to the cluster details page.

  9. 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 destination cluster.复制延迟小于60秒

    Note
    • When the cluster is created, DTS starts synchronizing data from the source PolarDB cluster. You must 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.

    • If the status is Precheck Failed, perform troubleshooting based on the error message.

      For example, if a trigger has been created in the source PolarDB cluster, the precheck fails. Delete the trigger in the source PolarDB cluster, and then click Continue. You can also 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 destination cluster

Before you perform this step, make sure that the replication latency of the destination PolarDB cluster is shorter than 60 seconds.

  1. Log on to the PolarDB console.

  2. Find the destination cluster and click the cluster ID.

  3. In the Upgrade section of the cluster details page, click Upgrade Switchover.升级切换

    Note
    • The switchover can typically be completed within 5 minutes.

    • After the switchover, the source PolarDB cluster becomes read-only, while the destination PolarDB cluster processes both read and write requests. DTS also changes the data replication direction by synchronizing incremental data from the destination PolarDB cluster to the source PolarDB cluster.

  4. 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)

      1. Select Switch with Endpoints (Connection Changes Not Required). The system automatically interchanges the endpoints of the source and destination PolarDB clusters. You do not need to change the configurations of your applications for the applications to connect to the destination PolarDB cluster.

        Important
        • Before you select this option, make sure that you are familiar with the items in the "Precautions" section of the Overview topic.

        • If the cluster that you want to upgrade is the source or destination of a task created in the 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?

      2. Then, click OK. In the message that appears, click Confirm.

    • Switch without Endpoints (Connection Changes Required)

      1. Select Switch without Endpoints (Connection Changes Required) in the dialog box.

      2. Then, click OK. In the message that appears, click Confirm.

      3. 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.

Note
  • 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 destination Multi-master Cluster Edition cluster. Otherwise, errors may occur during data synchronization.

Step 3: Complete the upgrade

After you complete the operations in Step 1: Create a PolarDB cluster, you must complete the upgrade within 30 days.

Important
  • Before you click Complete Upgrade, make sure that data migration is complete, and data synchronization is no longer required.

  • After you complete the upgrade, data is no longer synchronized from the destination PolarDB cluster to the source PolarDB cluster, and you can no longer roll back the upgrade. We recommend that you use the destination PolarDB cluster for a specific period of time, and complete the upgrade after you confirm that the cluster runs as normal.

  1. Log on to the PolarDB console.

  2. Find the destination cluster and click the cluster ID.

  3. In the PolarDB Upgrade section of the details page of the destination cluster, click Complete Upgrade.

  4. In the dialog box that appears, specify whether you want to disable binary logging for the destination cluster. Then, click OK.

    Note
    • After 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 have selected Disable Binary Logging for Destination Instance, the PolarDB cluster is restarted for the configuration to take effect.

    • If you no longer require the source PolarDB cluster, you can release the cluster. For information about how to release a cluster, see Release a cluster.

    • If you are performing an edition upgrade, the system randomly assigns primary nodes for processing write requests after you click OK in the Complete Upgrade dialog box.

(Optional) View the 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.

  1. Log on to the PolarDB console.

  2. Find the destination cluster and click the cluster ID.

  3. 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 in the DTS console.查看数据同步任务详情

  4. Click the ID of the synchronization task to go to the task details page.

  5. During an upgrade, if you want to change the objects that you want to synchronize, you can click Reselect Objects on the task details page. For example, the source PolarDB cluster may have new databases that also need to be included in the synchronization task.

(Optional) Roll back the upgrade

If an error occurs before you complete the upgrade, you can roll the cluster back to the version before the upgrade. After a rollback, the source PolarDB cluster handles both read and write requests, the destination PolarDB cluster becomes read-only, and data is synchronized from the source cluster to the destination cluster.

  1. Log on to the PolarDB console.

  2. Find the destination cluster and click the cluster ID.

  3. In the PolarDB Upgrade section of the details page of the destination cluster, click Upgrade Rollback.

  4. 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):

      1. The system automatically interchanges the endpoints of the source and destination PolarDB clusters. You do not need to change the configurations of your applications for the applications to connect to the source PolarDB cluster.

      2. Then, click OK. In the message that appears, click Confirm.

        After the rollback, the source PolarDB cluster processes both read and write requests, while the destination PolarDB cluster becomes read-only. DTS also changes the data replication direction by synchronizing incremental data from the source PolarDB cluster to the destination PolarDB cluster.

        Note

        When you roll back an edition upgrade, you can select the endpoints for the rollback.

    • Switch Back without Endpoints (Connection Changes Required):

      1. After the rollback, you must change the database endpoint in your applications at the earliest opportunity.

      2. After you click OK, the source PolarDB cluster processes both read and write requests, while the destination PolarDB cluster becomes read-only. DTS also changes the data replication direction by synchronizing incremental data from the source PolarDB cluster to the destination PolarDB cluster.

      3. 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.