All Products
Search
Document Center

PolarDB:Procedure

Last Updated:Mar 14, 2024

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 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, as shown in the following figure.

    • 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

PolarDB for MySQL 5.7

PolarDB for MySQL 8.0

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.

     
  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.

     

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

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

    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.

    Primary Zone

    The primary zone of the destination cluster.

    Enable Hot Standby Cluster

    Select whether to enable the hot standby cluster.

    • If the hot standby storage cluster feature is enabled, both the primary cluster and the hot standby storage cluster are deployed in the same region. The two clusters each have three replicas, which adds up to six replicas. This delivers higher SLA than when this feature is disabled.

    • If this feature is disabled, only the primary cluster is deployed. The cluster has three replicas, and the storage unit price is half of that when this feature is enabled. This delivers lower SLA than when this feature is enabled.

    Secondary Zone

    The secondary zone of the destination cluster.

    Specification

    The specification of the destination cluster.

    You can select General-purpose or Dedicated for Enterprise Edition.

    • Dedicated: Computing resources such as CPUs that are allocated to each cluster are exclusive to the cluster. This improves the stability and reliability.

    • General-purpose: Idle computing resources such as CPUs are shared among clusters on the same server for cost-effectiveness.

    For more information about the comparison between the types of specifications, see Comparison between general-purpose and dedicated compute nodes.

    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.

    Storage Type

    The storage type of the destination cluster.

    PolarDB provides two storage types: PSL5 and PSL4.

    • PSL5: the storage type supported by the previous versions of PolarDB. It is the default storage type for PolarDB clusters purchased before June 07, 2022. It delivers higher performance, reliability, and availability.

    • PSL4: a new storage type for PolarDB. This type uses the Smart-SSD technology developed in-house by Alibaba Cloud to compress and decompress data that is stored on SSD disks. It can minimize the storage costs of data while maintaining a high disk performance.

      Note

      The storage type of existing clusters cannot be changed. To use PSL4, we recommend that you purchase a new cluster, set the storage type to PSL4, and then migrate data to the new cluster.

    For more information about the two storage types, see Comparison between PSL4 and PSL5.

    Storage Engine

    The storage engine of the destination cluster.

    PolarDB provides two engine types: InnoDB and InnoDB & X-Engine.

    • InnoDB: deploys only the InnoDB storage engine.

    • InnoDB & X-Engine:: deploys both InnoDB and X-Engine. After you select this option, specify the ratio of X-Engine Memory Usage. For more information, see X-Engine Edition.

    Storage Billing Method

    The storage billing method of the destination cluster. PolarDB supports the following storage billing method:

    • Pay-as-you-go: You do not need to specify the storage capacity when you purchase clusters. The storage capacity is automatically increased when the amount of data increases. You are charged only for the storage that you use. Fees are deducted from your account on an hourly basis. For more information, see Billing method 2: pay-as-you-go.

    • Subscription: You need to pay for the storage capacity of a cluster in advance when you purchase the cluster. For more information, see Billing method 3: subscription.

    Storage Capacity

    The storage space of the destination cluster.

    Note

    This parameter is available only when Storage Billing Method is set to Subscription.

  5. Click Next: Cluster Configuration. Configure the following parameters.

    Parameter

    Description

    Cluster Name

    Select Auto-generate or Custom cluster name.

    • If you select Auto-generate, the system automatically generates a cluster name after the cluster is created. You can modify the automatically generated cluster name.

    • If you select Custom, you must enter a cluster name.

      • The name cannot start with http:// or https://.

      • The name must be 2 to 256 characters in length.

      • The name must start with a letter and can contain letters, digits, periods (.), underscores (_), and hyphens (-).

    Resource Group

    Select a resource group from the drop-down list. For more information, see Create a resource group.

    Network Type

    The network type is fixed as VPC. You do not need to configure this parameter. Configure the VPC and vSwitch.

    • If an existing VPC meets your network requirements, select the VPC. For example, if you have an existing ECS instance and the VPC to which the ECS instance belongs meets your network requirements, select this VPC.

    • Otherwise, use the default VPC and the default vSwitch.

      • Default VPC:

        • Only one VPC is specified as the default VPC in the region that you select.

        • The CIDR block of the default VPC uses a 16-bit subnet mask. For example, the CIDR block of the default VPC can be 192.168.0.0/16. This CIDR block provides up to 65,536 private IP addresses.

        • The default VPC does not count towards the quota of VPCs that you can create on Alibaba Cloud.

      • Default vSwitch:

        • Only one vSwitch is specified as the default vSwitch in the zone that you select.

        • The CIDR block of the default vSwitch uses a 20-bit subnet mask. For example, the CIDR block of the default vSwitch can be 192.168.0.0/20. This CIDR block provides up to 4,096 private IP addresses.

        • The default vSwitch does not count towards the quota of vSwitches that you can create in a VPC.

    • If the default VPC and vSwitch cannot meet your requirements, you can create your own VPC and vSwitch. For more information, see Create and manage a VPC.

    Enable Binary Logging

    Set Enable Binary Logging. For more information about binary logging, see Enable binary logging.

    Release Cluster

    Set the backup retention policy when the cluster is released.

    • Retain Last Automatic Backup (Automatic Backup before Release) (Default): The system retains the last backup when you delete the cluster.

    • Retain All Backups: The system retains all backups when you delete the cluster.

    • Delete All Backups (Cannot be Restored): The system retains no backups when you delete the cluster.

  6. Click Next: Confirm Order.

  7. Check the cluster configurations, and set Duration, Quantity, and whether to Auto-renewal for subscription clusters. The Duration and Auto-renewal parameters are valid only for subscription clusters.

  8. Read and select Terms of Service. Click Buy Now.

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

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

  11. 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 upgrade. Such tasks include data synchronization tasks, data migration tasks, and change tracking tasks. For more information, see Modify the objects to be synchronized.

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