All Products
Search
Document Center

PolarDB:Procedure

Last Updated:Jun 28, 2024

This topic describes how to upgrade PolarDB for MySQL clusters.

Preparations

Note

If you have completed the upgrade evaluation and no exceptions are thrown, skip the preparations. For more information about the upgrade evaluation, see Upgrade evaluation.

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 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. In the left-side navigation pane, choose Identities > Roles.

  3. Check whether a service-linked role named AliyunServiceRoleForPolarDB already exists in the list.

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

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

  4. On the Roles page, click Create Role.

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

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

  7. 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 can be either 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 a major version upgrade, you can use the 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 handle business traffic peaks in an efficient manner.

  • Analyze performance differences in the SQL execution of your PolarDB cluster before and after the upgrade.

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.

Note

We recommend that you complete the upgrade evaluation before the migration. For more information about the upgrade evaluation, see Upgrade evaluation.

  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 Billing Method to Subscription, Pay-as-you-go, or Serverless.

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

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

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

    Parameter

    Description

    Creation Method

    Select Upgrade/Migrate from PolarDB.

    Region

    The region of the source PolarDB for MySQL cluster.

    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.

    Database Engine

    The engine version of the destination PolarDB cluster.

      Note
      • If you want to perform a version upgrade, you can choose a version that is the same as or different from the source PolarDB cluster.

      • If you want to perform an edition upgrade, you can only choose MySQL 8.0.

    Database Edition

    The Database Edition is the same as that of the original cluster. You do not need to configure this parameter.

    Edition

    The edition of the destination PolarDB cluster.

      Note
      • If you want to perform a version upgrade, set the parameter to Cluster Edition (Recommended).

      • If you want to perform an edition upgrade, set the parameter to Multi-master Cluster (Database/Table).

    CPU Architecture

    The CPU architecture of the cluster is the same as that of the original cluster. You do not need to configure this parameter.

    Nodes

    The number of nodes is the same as that of the original cluster. You do not need to configure this parameter.

    Current Specification

    The selected specification of the destination cluster.

    PolarProxy Type

    The PolarProxy type of the cluster is the same as that of the original cluster. You do not need to configure this parameter.

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

  6. Read and select the terms of service. Click Buy Now.

  7. On the Purchase page, confirm the order and the payment method, and click Purchase.

    Note
    • After 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 only available 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.

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

  9. In the Upgrade section of the Basic Information page, check the value of the Replication Delay parameter. If the value is less than 60 seconds, perform the upgrade.复制延迟小于60秒

    Note
    • After 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 to process 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 less 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 Basic Information 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 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.

      2. Click OK.

    • Switch without Endpoints (Connection Changes Required)

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

      2. Click OK.

      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 (Optional) Roll back the upgrade.

  • 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 described 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 expected.

  1. Log on to the PolarDB console.

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

  3. In the Upgrade section of the Basic Information page, 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 Upgrade section of the Basic Information page, click the name of the DTS Data Synchronization Task to go to the synchronization task list 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 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. If you need to proceed with the major version upgrade after the rollback, you can perform the operations described in Step 2: Switch over to the destination cluster.

  1. Log on to the PolarDB console.

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

  3. In the Upgrade section of the Basic Information page, 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. Click OK.

        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 value of the Read/Write Status of Source PolarDB parameter changes to Read and Write, change the database endpoint in your applications at the earliest opportunity.