规划在 Azure SQL 数据库和 Azure SQL 托管实例中的 Azure 维护事件Plan for Azure maintenance events in Azure SQL Database and Azure SQL Managed Instance

适用于:是 Azure SQL 数据库 是Azure SQL 托管实例 APPLIES TO: yesAzure SQL Database yesAzure SQL Managed Instance

了解如何为在 Azure SQL 数据库和 Azure SQL 托管实例中的数据库上执行计划内维护事件做准备。Learn how to prepare for planned maintenance events on your database in Azure SQL Database and Azure SQL Managed Instance.

什么是计划内维护事件?What is a planned maintenance event?

Azure SQL 数据库和 Azure SQL 托管实例为每个数据库维护了一组正常运营所需的最低数量的数据库副本,其中一个副本是主副本。For each database, Azure SQL Database and Azure SQL Managed Instance maintain a quorum of database replicas where one replica is the primary. 主副本在任何时间都必须处于联机运行提供服务的状态,且至少要有一个辅助副本处于正常可用的状态。At all times, a primary replica must be online servicing, and at least one secondary replica must be healthy. 在计划内维护期间,所维护的数据库副本将进入脱机状态,一次脱机一个,目的是要有一个能够响应的主副本和至少一个辅助副本处于联机状态,确保不发生客户端停机。During planned maintenance, members of the database quorum will go offline one at a time, with the intent that there is one responding primary replica and at least one secondary replica online to ensure no client downtime. 当主副本需要进入脱机状态时,将启动重新配置/故障转移进程,其间,会有一个辅助副本变为新的主副本。When the primary replica needs to be brought offline, a reconfiguration/failover process will occur in which one secondary replica will become the new primary.

计划内维护事件期间会发生什么What to expect during a planned maintenance event

重新配置/故障转移通常在 30 秒内完成。Reconfigurations/failovers generally finish within 30 seconds. 平均 8 秒。The average is 8 seconds. 如果应用程序处于已连接状态,则必须重新连接至新的数据库健康主副本。If already connected, your application must reconnect to the healthy copy new primary replica of your database. 如果在进行连接时数据库正在进行重新配置,且新的主副本尚未处于联机状态,会显示错误 40613(数据库不可用):“服务器 '{servername}' 上的数据库 '{databasename}' 当前不可用。If a new connection is attempted while the database is undergoing a reconfiguration before the new primary replica is online, you get error 40613 (Database Unavailable): "Database '{databasename}' on server '{servername}' is not currently available. 请稍后重试连接。”Please retry the connection later." 如果数据库有一个长时间运行的查询,重新配置期间此查询会中断,需要重新启动。If your database has a long-running query, this query will be interrupted during a reconfiguration and will need to be restarted.

重试逻辑Retry logic

连接到云数据库服务的任何客户端生产应用程序均应实现一个可靠的连接重试逻辑Any client production application that connects to a cloud database service should implement a robust connection retry logic. 这有助于缓解此类状况,通常可以让最终用户清晰地看到错误。This will help mitigate these situations and should generally make the errors transparent to the end user.

频率Frequency

每个月平均会发生 1.7 个计划内维护事件。On average, 1.7 planned maintenance events occur each month.

资源运行状况Resource health

如果数据库发生登录失败的情况,请在 Azure 门户资源运行状况窗口中查看当前状态。If your database is experiencing log-on failures, check the Resource Health window in the Azure portal for the current status. 运行状况历史记录部分包含每个事件(如果有)的停机原因。The Health History section contains the downtime reason for each event (when available).

后续步骤Next steps