容錯移轉叢集和 AlwaysOn 可用性群組 (SQL Server)Failover Clustering and Always On Availability Groups (SQL Server)

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) - 僅限 Windows 適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) - Windows only

Always On 可用性群組Always On availability groups (也就是 SQL Server 2012 (11.x)SQL Server 2012 (11.x) 中所引進的高可用性和災害復原解決方案) 需要 Windows Server 容錯移轉叢集 (WSFC)。, the high availability and disaster recovery solution introduced in SQL Server 2012 (11.x)SQL Server 2012 (11.x), requires Windows Server Failover Clustering (WSFC). 此外,雖然 Always On 可用性群組Always On availability groups 不依賴 SQL ServerSQL Server 容錯移轉叢集,但是您可以使用容錯移轉叢集執行個體 (FCI) 來裝載可用性群組的可用性複本。Also, though Always On 可用性群組Always On availability groups is not dependent upon SQL ServerSQL Server Failover Clustering, you can use a failover clustering instance (FCI) to host an availability replica for an availability group. 請務必了解每個叢集技術的角色,也要知道設計您的 Always On 可用性群組Always On availability groups 環境時所必須考量的事項。It is important to know the role of each clustering technology, and to know what considerations are necessary as you design your Always On 可用性群組Always On availability groups environment.

注意

如需 Always On 可用性群組Always On availability groups 概念的資訊,請參閱 AlwaysOn 可用性群組概觀 (SQL Server)For information about Always On 可用性群組Always On availability groups concepts, see Overview of Always On Availability Groups (SQL Server).

Windows Server 容錯移轉叢集和可用性群組Windows Server Failover Clustering and Availability Groups

部署 Always On 可用性群組Always On availability groups 需要一個 Windows Server 容錯移轉叢集 (WSFC)。Deploying Always On 可用性群組Always On availability groups requires a Windows Server Failover Cluster (WSFC). 若要啟用 Always On 可用性群組Always On availability groupsSQL ServerSQL Server 執行個體必須位於 WSFC 節點上,且 WSFC 和節點必須在線上。To be enabled for Always On 可用性群組Always On availability groups, an instance of SQL ServerSQL Server must reside on a WSFC node, and the WSFC and node must be online. 此外,所指定可用性群組之每個可用性複本都必須位在相同 WSFC 的不同節點上。Furthermore, each availability replica of a given availability group must reside on a different node of the same WSFC. 唯一的例外狀況是在移轉至另一個 WSFC 期間,可用性群組可以暫時跨兩個叢集。The only exception is that while being migrated to another WSFC, an availability group can temporarily straddle two clusters.

Always On 可用性群組Always On availability groups 依賴 Windows Server 容錯移轉叢集 (WSFC) 來監視及管理屬於所指定可用性群組的可用性複本目前角色,並判斷容錯移轉事件對於可用性複本的影響程度。relies on the Windows Server Failover Cluster (WSFC) to monitor and manage the current roles of the availability replicas that belong to a given availability group and to determine how a failover event affects the availability replicas. 對於您建立的每個可用性群組,系統會建立一個 WSFC 資源群組。A WSFC resource group is created for every availability group that you create. WSFC 會監視此資源群組,以評估主要複本的健康狀態。The WSFC monitors this resource group to evaluate the health of the primary replica.

Always On 可用性群組Always On availability groups 的仲裁會以 WSFC 中的所有節點為基礎,而不論指定的叢集節點是否裝載任何可用性複本。The quorum for Always On 可用性群組Always On availability groups is based on all nodes in the WSFC regardless of whether a given cluster node hosts any availability replicas. 相較於資料庫鏡像, Always On 可用性群組Always On availability groups沒有見證角色。In contrast to database mirroring, there is no witness role in Always On 可用性群組Always On availability groups.

WSFC 的整體健康狀態是由叢集節點的仲裁投票所決定。The overall health of a WSFC is determined by the votes of quorum of nodes in the cluster. 如果 WSFC 因為未規劃的災害或由於持續硬體或通訊失敗而離線,則需要手動管理介入。If the WSFC goes offline because of an unplanned disaster, or due to a persistent hardware or communications failure, manual administrative intervention is required. Windows Server 或 WSFC 管理員需要強制仲裁,然後使非容錯設定中的存活叢集節點恢復上線。A Windows Server or WSFC administrator will need to force a quorum and then bring the surviving cluster nodes back online in a non-fault-tolerant configuration.

重要

Always On 可用性群組Always On availability groups 登錄機碼是 WSFC 的子機碼。registry keys are subkeys of the WSFC. 如果您刪除然後重新建立 WSFC,則必須在原始 WSFC 上裝載可用性複本的每個 Always On 可用性群組Always On availability groups 執行個體上,先停用然後重新啟用 SQL ServerSQL Server 功能。If you delete and re-create a WSFC, you must disable and re-enable the Always On 可用性群組Always On availability groups feature on each instance of SQL ServerSQL Server that hosted an availability replica on the original WSFC.

如需在 WSFC 節點上執行 SQL ServerSQL Server 以及 WSFC 仲裁的資訊,請參閱 SQL Server 的 Windows Server 容錯移轉叢集(WSFC) For information about running SQL ServerSQL Server on WSFC nodes and about WSFC quorum, see Windows Server Failover Clustering (WSFC) with SQL Server.

SQL ServerSQL Server 容錯移轉叢集執行個體 (FCI) 和可用性群組SQL ServerSQL Server Failover Cluster Instances (FCIs) and Availability Groups

您可以藉由實作 SQL ServerSQL Server FCI 連同 WSFC,在伺服器執行個體層級設定容錯移轉的第二層。You can set up a second layer of failover at the server-instance level by implementing SQL ServerSQL Server an FCI together with the WSFC. 可用性複本可由 SQL ServerSQL Server 獨立執行個體或 FCI 執行個體所裝載。An availability replica can be hosted by either a standalone instance of SQL ServerSQL Server or an FCI instance. 只有一個 FCI 夥伴可以裝載給定可用性群組的複本。Only one FCI partner can host a replica for a given availability group. 在 FCI 上執行可用性複本時,可用性群組的可能擁有者清單只包含使用中 FCI 節點。When an availability replica is running on an FCI, the possible owners list for the availability group will contain only the active FCI node.

Always On 可用性群組Always On availability groups 不依賴任何形式的共用儲存體。does not depend on any form of shared storage. 不過,如果您使用 SQL ServerSQL Server 容錯移轉叢集執行個體 (FCI) 來裝載一個或多個可用性複本,依照標準 SQL Server 容錯移轉叢集執行個體安裝,這些 FCI 都需要共用儲存體。However, if you use a SQL ServerSQL Server failover cluster instance (FCI) to host one or more availability replicas, each of those FCIs will require shared storage as per standard SQL Server failover cluster instance installation.

如需其他必要條件的詳細資訊,請參閱 AlwaysOn 可用性群組的必要條件、限制和建議 的<使用 SQL Server 容錯移轉叢集執行個體 (FCI) 裝載可用性複本的必要條件和限制>一節。For more information about additional prerequisites, see the "Prerequisites and Restrictions for Using a SQL Server Failover Cluster Instance (FCI) to Host an Availability Replica" section of Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server).

容錯移轉叢集執行個體和可用性群組的比較Comparison of Failover Cluster Instances and Availability Groups

無論 FCI 中節點的數目有多少,整個 FCI 只能裝載可用性群組的單一複本。Regardless of the number of nodes in the FCI, an entire FCI hosts a single replica within an availability group. 下表描述 FCI 節點和可用性群組複本之間的概念差異。The following table describes the distinctions in concepts between nodes in an FCI and replicas within an availability group.

FCI 內的節點Nodes within an FCI 可用性群組內的複本Replicas within an availability group
使用 WSFCUses WSFC Yes Yes
保護等級Protection level 執行個體Instance 資料庫Database
儲存體類型Storage type 共用Shared 非共用Non-shared

可用性群組中的複本不會共用儲存體,而 FCI 裝載的複本則會使用該 FCI 所需的共用儲存方案。While the replicas in an availability group do not share storage, a replica that is hosted by an FCI uses a shared storage solution as required by that FCI. 只有 FCI 內的節點共用儲存方案,可用性群組的複本之間不共用儲存方案。The storage solution is shared only by nodes within the FCI and not between replicas of the availability group.
儲存方案Storage solutions 直接附加、SAN、掛接點、SMBDirect attached, SAN, mount points, SMB 取決於節點類型Depends on node type
可讀取次要Readable secondaries 否*No* Yes
適用的容錯移轉原則設定Applicable failover policy settings WSFC 仲裁WSFC quorum

FCI 特定FCI-specific

可用性群組設定**Availability group settings**
WSFC 仲裁WSFC quorum

可用性群組設定Availability group settings
容錯移轉資源Failed-over resources 伺服器、執行個體和資料庫Server, instance, and database 僅限資料庫Database only

*可用性群組中的同步次要複本一律在其各自的 SQL ServerSQL Server 執行個體上執行,而 FCI 中的次要節點實際上尚未啟動其各自的 SQL ServerSQL Server 執行個體,因此不可讀取。*Whereas synchronous secondary replicas in an availability group are always running on their respective SQL ServerSQL Server instances, secondary nodes in an FCI actually have not started their respective SQL ServerSQL Server instances and are therefore not readable. 在 FCI 中,次要節點只在 FCI 容錯移轉期間資源群組擁有權轉移到它自己時才會啟動其 SQL ServerSQL Server 執行個體。In an FCI, a secondary node starts its SQL ServerSQL Server instance only when the resource group ownership is transferred to it during an FCI failover. 不過,在使用中 FCI 節點上,當 FCI 裝載的資料庫屬於可用性群組時,如果本機可用性複本以可讀取的次要複本方式執行,資料庫就是可讀取的。However, on the active FCI node, when an FCI-hosted database belongs to an availability group, if the local availability replica is running as a readable secondary replica, the database is readable.

**可用性群組的容錯移轉原則設定適用於所有複本,無論複本裝載於獨立執行個體或 FCI 執行個體。**Failover policy settings for the availability group apply to all replicas, whether it is hosted in a standalone instance or an FCI instance.

注意

如需 SQL ServerSQL Server 版本的 FCI 和 Always On 可用性群組節點數目 的詳細資訊,請參閱 SQL Server 2012 版本支援的功能 (https://go.microsoft.com/fwlink/?linkid=232473)。For more information about Number of nodes within FCIs and Always On Availability Groups for different editions of SQL ServerSQL Server, see Features Supported by the Editions of SQL Server 2012 (https://go.microsoft.com/fwlink/?linkid=232473).

FCI 裝載可用性複本的考量Considerations for hosting an Availability Replica on an FCI

重要

如果您計劃在 SQL Server 容錯移轉叢集執行個體 (FCI) 裝載可用性複本,請確定 Windows Server 2008 主機節點符合容錯移轉叢集執行個體 (FCI) 的 AlwaysOn 必要條件和限制。If you plan to host an availability replica on a SQL Server Failover Cluster Instance (FCI), ensure that the Windows Server 2008 host nodes meet the Always On prerequisites and restrictions for Failover Cluster Instances (FCIs). 如需詳細資訊,請參閱 AlwaysOn 可用性群組的必要條件、限制和建議 (SQL Server)For more information, see Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server).

SQL ServerSQL Server 容錯移轉叢集執行個體 (FCI) 不支援依照可用性群組進行自動容錯移轉,因此任何由 FCI 裝載的可用性複本只能設定為手動容錯移轉。Failover Cluster Instances (FCIs) do not support automatic failover by availability groups, so any availability replica that is hosted by an FCI can only be configured for manual failover.

您可能需要設定 WSFC,使其包含並非在所有節點都可使用的共用磁碟。You might need to configure a WSFC to include shared disks that are not available on all nodes. 例如,假設有一個 WSFC 跨兩個資料中心,其共有三個節點。For example, consider a WSFC across two data centers with three nodes. 在主要資料中心的兩個節點裝載 SQL Server 容錯移轉叢集執行個體 (FCI),且可存取相同的共用磁碟。Two of the nodes host a SQL Server failover cluster instance (FCI) in the primary data center and have access to the same shared disks. 在另一個資料中心,第三個節點裝載 SQL Server 獨立執行個體,而且無法存取主要資料中心的共用磁碟。The third node hosts a stand-alone instance of SQL Server in a different data center and does not have access to the shared disks from the primary data center. 如果 FCI 裝載主要複本,且獨立執行個體裝載次要複本,此 WSFC 設定就會支援可用性群組的部署。This WSFC configuration supports the deployment of an availability group if the FCI hosts the primary replica and the stand-alone instance hosts the secondary replica.

當您選擇讓 FCI 裝載給定可用性群組的可用性複本時,請確定 FCI 容錯移轉不會使單一 WSFC 節點嘗試裝載同一個可用性群組的兩個可用性複本。When choosing an FCI to host an availability replica for a given availability group, ensure that an FCI failover could not potentially cause a single WSFC node to attempt to host two availability replicas for the same availability group.

下列範例案例說明這個組態可能會如何導致問題的發生:The following example scenario illustrates how this configuration could lead to problems:

Marcel 設定包含兩個節點 NODE01NODE02 的 WSFC。Marcel configures two a WSFC with two nodes, NODE01 and NODE02. 他將 SQL ServerSQL Server 容錯移轉叢集執行個體 fciInstance1同時安裝在 NODE01NODE02 上,其中 NODE01fciInstance1的目前擁有者。He installs a SQL ServerSQL Server failover cluster instance, fciInstance1, on both NODE01 and NODE02 where NODE01 is the current owner for fciInstance1.
Marcel 會在 NODE02上安裝另一個 SQL ServerSQL Server執行個體 Instance3,這是獨立執行個體。On NODE02, Marcel installs another instance of SQL ServerSQL Server, Instance3, which is a stand-alone instance.
Marcel 在 NODE01上讓 fciInstance1 啟用 Always On 可用性群組Always On availability groupsOn NODE01, Marcel enables fciInstance1 for Always On 可用性群組Always On availability groups. 他在 NODE02上讓 Instance3 啟用 Always On 可用性群組Always On availability groupsOn NODE02, he enables Instance3 for Always On 可用性群組Always On availability groups. 接著他設定可用性群組,由 fciInstance1 裝載其主要複本,並由 Instance3 裝載其次要複本。Then he sets up an availability group for which fciInstance1 hosts the primary replica, and Instance3 hosts the secondary replica.
在某個時間點,fciInstance1 會變得無法在 NODE01 上使用,且 WSFC 會造成 fciInstance1 容錯移轉到 NODE02At some point fciInstance1 becomes unavailable on NODE01, and the WSFC causes a failover of fciInstance1 to NODE02. 在容錯移轉之後, fciInstance1 就是具有 Always On 可用性群組Always On availability groups功能的執行個體,於 NODE02的主要角色之下執行。After the failover, fciInstance1 is a Always On 可用性群組Always On availability groups-enabled instance running under the primary role on NODE02. 但是, Instance3 現在位於與 fciInstance1相同的 WSFC 節點上。However, Instance3 now resides on the same WSFC node as fciInstance1. 這樣會違反 Always On 可用性群組Always On availability groups 條件約束。This violates the Always On 可用性群組Always On availability groups constraint.
若要更正此案例所呈現的問題,獨立執行個體 Instance3 必須位於與 NODE01NODE02 相同 WSFC 內的另一個節點上。To correct the problem that this scenario presents, the stand-alone instance, Instance3, must reside on another node in the same WSFC as NODE01 and NODE02.

如需 SQL ServerSQL Server FCI 的詳細資訊,請參閱 Always On 容錯移轉叢集執行個體 (SQL Server)For more information about SQL ServerSQL Server FCIs, see Always On Failover Cluster Instances (SQL Server).

WSFC 容錯移轉叢集管理員與可用性群組一起使用的限制Restrictions on Using The WSFC Failover Cluster Manager with Availability Groups

不要使用容錯移轉叢集管理員操作可用性群組,例如:Do not use the Failover Cluster Manager to manipulate availability groups, for example:

  • 請勿在可用性群組的叢集服務 (資源群組) 中加入或移除資源。Do not add or remove resources in the clustered service (resource group) for the availability group.

  • 請勿變更任何可用性群組屬性,例如可能的擁有者和慣用擁有者。Do not change any availability group properties, such as the possible owners and preferred owners. 可用性群組會自動設定這些屬性。These properties are set automatically by the availability group.

  • 請不要使用容錯移轉叢集管理員將可用性群組移至不同的節點或容錯移轉可用性群組。Do not use the Failover Cluster Manager to move availability groups to different nodes or to fail over availability groups. 容錯移轉叢集管理員不會察覺可用性複本的同步處理狀態,而且這樣做可能會造成停機時間延長。The Failover Cluster Manager is not aware of the synchronization status of the availability replicas, and doing so can lead to extended downtime. 您必須使用 Transact-SQLTransact-SQLSQL Server Management StudioSQL Server Management StudioYou must use Transact-SQLTransact-SQL or SQL Server Management StudioSQL Server Management Studio.

警告

使用容錯移轉叢集管理員將裝載可用性群組的「容錯移轉叢集執行個體」 移至「已」 裝載相同可用性群組複本的節點時,可能會導致遺失可用性群組複本,使其無法在目標節點上線。Using the Failover Cluster Manager to move a failover cluster instance hosting an availability group to a node that is already hosting a replica of the same availability group may result in the loss of the availability group replica, preventing it from being brought online on the target node. 容錯移轉叢集的單一節點無法裝載相同可用性群組的多個複本。A single node of a failover cluster cannot host more than one replica for the same availability group. 如需如何發生這種情況以及如何復原的詳細資訊,請參閱部落格:Replica unexpectedly dropped in availability group (在可用性群組中意外卸除複本)。For more information on how this occurs, and how to recover, see the blog Replica unexpectedly dropped in availability group.

另請參閱See Also

AlwaysOn 可用性群組概觀 (SQL Server) Overview of Always On Availability Groups (SQL Server)
啟用和停用 AlwaysOn 可用性群組 (SQL Server) Enable and Disable Always On Availability Groups (SQL Server)
監視可用性群組 (Transact-SQL) Monitor Availability Groups (Transact-SQL)
AlwaysOn 容錯移轉叢集執行個體 (SQL Server)Always On Failover Cluster Instances (SQL Server)