Azure Database for MySQL 单一服务器中的主版本升级Major version upgrade in Azure Database for MySQL Single Server

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

重要

Azure Database for MySQL 单一服务器的主版本升级为公共预览版。Major version upgrade for Azure database for MySQL Single Server is in public preview.

本文介绍了如何就地升级 Azure Database for MySQL 单一服务器中的 MySQL 主版本。This article describes how you can upgrade your MySQL major version in-place in Azure Database for MySQL single server.

利用此功能,客户可以轻松地将 MySQL 5.6 服务器就地升级到 MySQL 5.7,无需移动任何数据,也无需更改应用程序连接字符串。This feature will enable customers to perform in-place upgrades of their MySQL 5.6 servers to MySQL 5.7 with a click of button without any data movement or the need of any application connection string changes.

备注

使用 Azure 门户执行从 MySQL 5.6 到 MySQL 5.7 的主版本升级Perform major version upgrade from MySQL 5.6 to MySQL 5.7 using Azure portal

使用 Azure 门户按照以下步骤为 Azure Database for MySQL 5.6 服务器执行主版本升级Follow these steps to perform major version upgrade for your Azure Database of MySQL 5.6 server using Azure portal

重要

建议首先在还原后的服务器副本上执行升级,而不是直接升级生产服务器。We recommend to perform upgrade first on restored copy of the server rather than upgrading production directly. 请参阅如何执行时间点还原See how to perform point-in-time restore.

  1. Azure 门户中,选择你的现有 Azure Database for MySQL 5.6 服务器。In the Azure portal, select your existing Azure Database for MySQL 5.6 server.

  2. 从“概述”页上,单击工具栏中的“升级”按钮。From the Overview page, click the Upgrade button in the toolbar.

  3. 在“升级”部分,选择“确定”以将 Azure database for MySQL 5.6 服务器升级为 5.7 服务器。In the Upgrade section, select OK to upgrade Azure database for MySQL 5.6 server to 5.7 server.

    Azure Database for MySQL - 概述 - 升级

  4. 一条通知会确认升级是否成功。A notification will confirm that upgrade is successful.

使用 Azure CLI 执行从 MySQL 5.6 到 MySQL 5.7 的主版本升级Perform major version upgrade from MySQL 5.6 to MySQL 5.7 using Azure CLI

使用 Azure CLI 按照以下步骤为 Azure Database for MySQL 5.6 服务器执行主版本升级Follow these steps to perform major version upgrade for your Azure Database of MySQL 5.6 server using Azure CLI

重要

建议首先在还原后的服务器副本上执行升级,而不是直接升级生产服务器。We recommend to perform upgrade first on restored copy of the server rather than upgrading production directly. 请参阅如何执行时间点还原See how to perform point-in-time restore.

  1. 安装适用于 Windows 的 Azure CLI 以运行升级命令。Install Azure CLI for Windows to run the upgrade commands.

    此升级需要 2.16.0 或更高版本的 Azure CLI。This upgrade requires version 2.16.0 or later of the Azure CLI. 运行 az version 以查找安装的版本和依赖库。Run az version to find the version and dependent libraries that are installed. 若要升级到最新版本,请运行 az upgrade。To upgrade to the latest version, run az upgrade.

  2. 在登录之后,请运行 az mysql server upgrade 命令:After you sign in, run the az mysql server upgrade command:

    az mysql server upgrade --name testsvr --resource-group testgroup --subscription MySubscription --target-server-version 5.7"
    

    命令提示符会显示“-Running”消息。The command prompt shows the "-Running" message. 此消息不再显示即表示版本升级完成。After this message is no longer displayed, the version upgrade is complete.

使用 Azure 门户在只读副本上执行从 MySQL 5.6 到 MySQL 5.7 的主版本升级Perform major version upgrade from MySQL 5.6 to MySQL 5.7 on read replica using Azure portal

  1. Azure 门户中,选择你的现有 Azure Database for MySQL 5.6 只读副本服务器。In the Azure portal, select your existing Azure Database for MySQL 5.6 read replica server.

  2. 从“概述”页上,单击工具栏中的“升级”按钮。From the Overview page, click the Upgrade button in the toolbar.

  3. 在“升级”部分,选择“确定”以将 Azure database for MySQL 5.6 只读副本服务器升级为 5.7 服务器。In the Upgrade section, select OK to upgrade Azure database for MySQL 5.6 read replica server to 5.7 server.

    Azure Database for MySQL - 概述 - 升级

  4. 一条通知会确认升级是否成功。A notification will confirm that upgrade is successful.

  5. 在“概述”页上,确认 Azure Database for MySQL 只读副本服务器版本为 5.7。From the Overview page, confirm that your Azure database for MySQL read replica server version is 5.7.

  6. 现在请前往主服务器,并在该服务器上执行主版本升级Now go to your primary server and Perform major version upgrade on it.

使用只读副本执行从 MySQL 5.6 到 MySQL 5.7 停机时间最短的主版本升级Perform minimal downtime major version upgrade from MySQL 5.6 to MySQL 5.7 using read replicas

利用只读副本,可以执行从 MySQL 5.6 到 MySQL 5.7 停机时间最短的主版本升级。You can perform minimal downtime major version upgrade from MySQL 5.6 to MySQL 5.7 by utilizing read replicas. 其原理是先将服务器的只读副本升级到 5.7,然后对应用程序进行故障转移以指向只读副本并使其成为新的主服务器。The idea is to upgrade the read replica of your server to 5.7 first and later failover your application to point to read replica and make it a new primary.

  1. Azure 门户中,选择现有 Azure Database for MySQL 5.6。In the Azure portal, select your existing Azure Database for MySQL 5.6.

  2. 从主服务器创建只读副本Create a read replica from your primary server.

  3. 将只读副本升级到版本 5.7。Upgrade your read replica to version 5.7.

  4. 确认副本服务器的运行版本为 5.7 后,断开应用程序和主服务器之间的连接。Once you confirm that the replica server is running on version 5.7, stop your application from connecting to your primary server.

  5. 检查复制状态,确保副本服务器与主服务器完全同步,从而让所有数据都处于同步状态,并确保主服务器中没有执行任何新的操作。Check replication status, and make sure replica is all caught up with primary so all the data is in sync and ensure there are no new operations performed in primary.

    在副本服务器上调用 show slave status 命令查看复制状态。Call the show slave status command on the replica server to view the replication status.

    SHOW SLAVE STATUS\G
    

    如果 Slave_IO_RunningSlave_SQL_Running 状态为“yes”,并且 Seconds_Behind_Master 的值为“0”,则表示复制正常运行。If the state of Slave_IO_Running and Slave_SQL_Running are "yes" and the value of Seconds_Behind_Master is "0", replication is working well. Seconds_Behind_Master 指示副本的陈旧状态。Seconds_Behind_Master indicates how late the replica is. 如果其值不为“0”,则表示副本正在处理更新。If the value isn't "0", it means that the replica is processing updates. 确认 Seconds_Behind_Master 为“0”后即可放心地停止复制。Once you confirm Seconds_Behind_Master is "0" it's safe to stop replication.

  6. 通过停止复制,可将只读副本提升为主服务器。Promote your read replica to primary by stopping replication.

  7. 将应用程序指向运行服务器 5.7 的新的主服务器(也就是之前的副本服务器)。Point your application to the new primary (former replica) which is running server 5.7. 每个服务器都有唯一的连接字符串。Each server has a unique connection string. 更新应用程序,使之指向(以前的)副本而不是源。Update your application to point to the (former) replica instead of the source.

备注

此方案仅在步骤 4、5 和 6 中出现停机。This scenario will have downtime during steps 4, 5 and 6 only.

常见问题Frequently asked questions

我们的生产环境中有需要升级的 MySQL v5.6,此升级功能什么时候将正式发布?When will this upgrade feature be GA as we have MySQL v5.6 in our production environment that we need to upgrade?

计划在 MySQL v5.6 停用之前正式发布此功能。The GA of this feature is planned before MySQL v5.6 retirement. 但是,此功能已准备好用于生产环境,并且由 Azure 提供完全支持,因此你应该可以放心地在你的环境中运行它。However, the feature is production ready and fully supported by Azure so you should run it with confidence on your environment. 强烈建议你首先在还原后的服务器副本上运行和测试它,以便你可以估计升级期间的停机时间,并执行应用程序兼容性测试,然后再在生产环境中运行应用程序。这是推荐的最佳做法。As a recommended best practice, we strongly suggest you to run and test it first on a restored copy of the server so you can estimate the downtime during upgrade, and perform application compatibility test before you run it on production. 有关详细信息,请参阅如何执行时间点还原(用于创建服务器的时间点副本)。For more information, see how to perform point-in-time restore to create a point in time copy of your server.

这是否会导致服务器停机?如果会,会停机多长时间?Will this cause downtime of the server and if so, how long?

是的,服务器在升级过程中将不可用。因此,我们建议你在计划内维护时段执行此操作。Yes, the server will be unavailable during the upgrade process so we recommend you perform this operation during your planned maintenance window. 估计的停机时间取决于数据库大小、预配的存储大小(预配的 IOPS)以及数据库中的表的数量。The estimated downtime depends on the database size, storage size provisioned (IOPs provisioned), and the number of tables on the database. 升级时间与服务器中表的数量成正比。基本 SKU 服务器的升级预计需要更长时间,因为它在标准存储平台上。The upgrade time is directly proportional to the number of tables on the server.The upgrades of Basic SKU servers are expected to take longer time as it is on standard storage platform. 为了估计服务器环境的停机时间,建议你首先在还原后的服务器副本上执行升级。To estimate the downtime for your server environment, we recommend to first perform upgrade on restored copy of the server. 请考虑使用只读副本执行从 MySQL 5.6 到 MySQL 5.7 停机时间最短的主版本升级。Consider performing minimal downtime major version upgrade from MySQL 5.6 to MySQL 5.7 using read replica.

如果未选择在 2021 年 2 月 5 日之前升级 MySQL 5.6 服务器,会发生什么情况?What will happen if we do not choose to upgrade our MySQL v5.6 server before February 5, 2021?

你仍可像以前一样继续运行 MySQL v5.6 服务器。You can still continue running your MySQL v5.6 server as before. Azure 永远不会在服务器上执行强制升级。Azure will never perform force upgrade on your server. 但是,会应用 Azure Database for MySQL 版本控制策略中所述的限制。However, the restrictions documented in Azure Database for MySQL versioning policy will apply.

后续步骤Next steps

了解 Azure Database for MySQL 版本控制策略Learn about Azure Database for MySQL versioning policy.