設定 SharePoint Server 的 SQL Server AlwaysOn 可用性群組Configure SQL Server AlwaysOn Availability Groups for SharePoint Server

摘要: 了解如何建立和設定適用於 SharePoint Server 2016 和 SharePoint 2013 伺服器陣列的 SQL Server Always On 可用性群組。Summary: Learn how to create and configure a SQL Server Always On Availability Group for a SharePoint Server 2016 and SharePoint 2013 farm.

本文提供建立和設定適用於 SharePoint Server 2016 伺服器陣列的 Microsoft SQL Server 2014 (SP1) 或 Microsoft SQL Server 2016 Always On 可用性群組,以及適用於 SharePoint 2013 伺服器陣列的 SQL Server 2012 Always On 可用性群組,相關的必要資訊和詳細程序。This article provides the required information and detailed procedures to create and configure a Microsoft SQL Server 2014 (SP1) or Microsoft SQL Server 2016 Always On Availability Group for a SharePoint Server 2016 farm and a SQL Server 2012 Always On Availability Group for a SharePoint 2013 farm.

重要

本文中的步驟示範如何部署新的 SharePoint 伺服器陣列,並且未涵蓋從 SQL Server 2008 R2 Service Pack 1 (SP1) 或 SQL Server 2012 升級為 SQL Server 2014 (SP1) 或 SQL Server 2016。The steps in this article show how to deploy a new SharePoint farm and doesn't cover upgrading from SQL Server 2008 R2 with Service Pack 1 (SP1) or SQL Server 2012 to SQL Server 2014 (SP1) or SQL Server 2016.

注意

本文中的步驟也適用於 SharePoint Foundation 2013 和 SharePoint Server 2013。針對這兩項產品,這些步驟可用來部署新的 SharePoint 伺服器陣列,但未包含從 SQL Server 2008 R2 升級到 SQL Server 2012。The steps in this article also apply to both SharePoint Foundation 2013 and SharePoint Server 2013. With both of these products these steps are to deploy a new SharePoint farm and don't cover upgrading from SQL Server 2008 R2 to SQL Server 2012.

程序概觀Process overview

建議您遵循所顯示順序的安裝和設定步驟,來部署使用 Always On 可用性群組的 SharePoint 伺服器陣列:We recommend following the installation and configuration steps in the order shown to deploy a SharePoint farm that uses an Always On availability group:

  • 選取或建立 Windows Server容錯移轉叢集。Select or create a Windows Server failover cluster.

  • 在每個叢集節點上安裝 SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012。Install SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012 on each cluster node.

  • 建立與設定可用性群組。Create and configure an availability group.

  • 安裝並設定 SharePoint Server 2016、SharePoint Server 2013 或 SharePoint Foundation 2013。Install and configure SharePoint Server 2016, SharePoint Server 2013, or SharePoint Foundation 2013.

  • 將 SharePoint 資料庫新增至可用性群組。Add the SharePoint databases to the availability group.

  • 測試可用性群組的容錯移轉。Test failover for the availability group.

開始之前Before you begin

開始部署之前,請檢閱下列有關 SQL Server Always On、支援 Always On 的技術及 SharePoint Server 2016 的資訊:Before you begin deployment, review the following information about SQL Server Always On, the technologies that support Always On, and SharePoint Server 2016:

  • 知識與技能需求Knowledge and skill requirements

  • Always On 可用性群組概念Always On Availability Group concepts

  • 硬體及軟體需求Hardware and software requirements

  • 權限Permissions

知識與技能需求Knowledge and skill requirements

為了實作 SQL Server Always On 可用性群組以作為高可用性和災害復原解決方案,有數種技術要進行互動且必須正確安裝與設定。因此,建議負責為 SharePoint 產品 設定 Always On 環境的小組具備下列技術的使用知識與實機操作技能:To implement SQL Server Always On Availability Groups as a high availability and disaster recovery solution, several technologies interact and have to be installed and configured correctly. We recommend that the team responsible for setting up an Always On environment for SharePoint products has a working knowledge of, and hands-on skills with the following technologies:

  • Windows Server 容錯移轉叢集 (WSFC) 服務Windows Server Failover Clustering (WSFC) services

  • SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012

  • SharePoint Server 2016SharePoint Server 2016

  • SharePoint Server 2013SharePoint Server 2013

  • SharePoint Foundation 2013SharePoint Foundation 2013

SQL Server Always On 可用性群組概念SQL Server Always On Availability Group concepts

可用性群組是由下列元件所組成:An availability group consists of the following components:

  • 複本,此為一組名稱為可用性資料庫的離散使用者資料庫,可當成單一單位一起進行容錯移轉。SQL Server 2014 (SP1) 和 SQL Server 2016 中的每個可用性群組都支援一個主要複本且最多可支援八個次要複本。SQL Server 2012 中的每個可用性群組都支援一個主要複本且最多可支援四個次要複本。Replicas, which are a discrete set of user databases called availability databases that fail over together as a single unit. Every availability group in SQL Server 2014 (SP1) and SQL Server 2016 supports one primary replica and up to eight secondary replicas. Every availability group in SQL Server 2012 supports one primary replica and up to four secondary replicas.

  • SQL Server 的特定執行個體,可主控每個複本以及維護每個隸屬於可用性群組之資料庫的本機複本。A specific instance of SQL Server to host each replica and to maintain a local copy of each database that belongs to the availability group.

如需詳細資訊,請參閱<Always On 可用性群組 (SQL Server)>和<Always On 可用性群組概觀 (SQL Server)Always On Availability Groups (SQL Server) and Overview of Always On Availability Groups (SQL Server)

複本與容錯移轉Replicas and failover

主要複本讓可用性資料庫可用於來自用戶端的讀寫連線,以及針對每個主要資料庫將交易記錄傳送至每個次要複本。每個次要複本會將交易記錄套用至其次要資料庫。The primary replica makes the availability databases available for read-write connections from clients and sends transaction log records for each primary database to every secondary replica. Each secondary replica applies transaction log records to its secondary databases.

所有複本都可以在非同步認可模式下執行,或者最多可以有三個複本在同步認可模式下執行。如需同步與非同步認可模式的詳細資訊,請參閱可用性模式 (AlwaysOn 可用性群組)All replicas can run under asynchronous-commit mode, or up to three of them can run under synchronous-commit mode. For more information about synchronous and asynchronous commit mode, see Availability Modes (AlwaysOn Availability Groups).

注意

資料庫問題 (例如,因為資料檔遺失、資料庫刪除或交易記錄毀損而變成有疑問的資料庫 ) 不會導致容錯移轉。Database issues, such as a database becoming suspect due to a loss of a data file, deletion of a database, or corruption of a transaction log do not cause failovers.

請閱讀下列文章,以了解有關 SQL Server Always On 技術的重要概念:Read the following articles to learn important concepts about SQL Server Always On technology:

重要

您可以在 Windows Server 核心上安裝 SQL Server 2012 以提升安全性並減少維護作業,但是無法在 Windows Server 核心上安裝 SharePoint Server 2016。如需詳細資訊,請參閱<適用於 Windows Server 2008 R2 的伺服器核心>。如需伺服器核心和 Windows Server 2012 的詳細資訊,請參閱<Windows Server 安裝選項>。You can install SQL Server 2012 on Windows Server core to improve security and reduce maintenance, but you cannot install SharePoint Server 2016 on Windows Server core. For more information, see Server Core for Windows Server 2008 R2. For information about server core and Windows Server 2012, see Windows Server Installation Options.

Windows Server 容錯移轉叢集Windows Server Failover Clustering

若要建立和使用 SQL Server 2014 (SP1) 或 SQL Server 2016 Always On 可用性群組,您必須將兩個 SQL Server 版本安裝在 Windows Server 容錯移轉叢集 (WSFC) 叢集。如需詳細資訊,請參閱 SQL Server 的 Windows Server 容錯移轉叢集 (WSFC)SQL Server 的 Windows Server 容錯移轉叢集 (WSFC) (適用於 SQL Server 2016)。To create and use SQL Server 2014 (SP1) or SQL Server 2016 Always On Availability Groups, you have to install both SQL Server versions on a Windows Server Failover Clustering (WSFC) cluster. For more information, see Windows Server Failover Clustering (WSFC) with SQL Server and for SQL Server 2016, Windows Server Failover Clustering (WSFC) with SQL Server.

若要建立和使用 SQL Server 2012 AlwaysOn 可用性群組,您必須將 SQL Server 2012 安裝在 Windows Server 容錯移轉叢集 (WSFC) 叢集上。To create and use SQL Server 2012 AlwaysOn Availability Groups, you have to install SQL Server 2012 on a Windows Server Failover Clustering (WSFC) cluster.

儘管設定 WSFC 叢集已超出本文範圍,您還是應該在安裝與設定叢集之前注意下列需求:Although configuring a WSFC cluster is out of the scope for this article, you should be aware of the following requirements before you install and configure a cluster:

設定容錯移轉叢集和 Always On 時一個非常重要的層面是判斷叢集節點所需的仲裁投票。A very important aspect of configuring failover clustering and Always On is determining the quorum votes that are needed for the cluster nodes.

容錯移轉叢集是以投票演算法為基礎,其中有一半以上的投票者或仲裁必須連線且能夠彼此通訊。由於指定的叢集含有特定的節點數目和一個特定的仲裁設定,因此,叢集服務能夠判斷構成仲裁的項目。如果投票者數目低於所需的多數,則所有節點上的叢集服務將會停止。Failover clustering is based on a voting algorithm where more than one half of the voters, or quorum, must be online and able to communicate with each other. Because a given cluster has a specific number of nodes and a specific quorum configuration, the cluster service is able to determine what constitutes a quorum. The cluster service will stop on all the nodes if the number of voters drops below the required majority.

如需詳細資訊,請參閱<WSFC 仲裁模式和投票設定 (SQL Server)>和<設定叢集仲裁 NodeWeight 設定>。For more information, see WSFC Quorum Modes and Voting Configuration (SQL Server) and Configure Cluster Quorum NodeWeight Settings.

SharePoint Server 2016、SharePoint Foundation 2013 和 SharePoint Server 2013SharePoint Server 2016, SharePoint Foundation 2013, and SharePoint Server 2013

某些 SharePoint Server 資料庫不支援 SQL Server Always On 可用性群組。建議您先檢閱 SharePoint 資料庫支援的高可用性和災害復原選項,再設定 Always On 環境。您也應該檢閱 SharePoint Server 2016 的硬體及軟體需求SharePoint 2013 的硬體及軟體需求Some SharePoint Server databases do not support SQL Server Always On Availability Groups. We recommend that you review Supported high availability and disaster recovery options for SharePoint databases before you configure an Always On environment. You should also review Hardware and software requirements for SharePoint Server 2016 and Hardware and software requirements for SharePoint 2013.

設定適用於 SharePoint 之 Always On 可用性群組的詳細步驟Detailed steps to configure an Always On Availability Group for SharePoint

下圖顯示 SharePoint Server 2016 伺服器陣列 (SPHA_farm),其中使用名為 SP_AG1 的可用性群組。我們將使用 SPHA_farm 作為步驟中的參考範例來設定 Always On。The following illustration shows a SharePoint Server 2016 farm (SPHA_farm) that uses an availability group named SP_AG1. We'll use SPHA_farm as reference example in our steps to configure Always On.

使用 AlwaysOn 可用性群組的 SharePoint Server 伺服器陣列

準備 Windows Server 叢集環境Prepare the Windows Server cluster environment

存取或建立可用來在每個叢集節點上安裝 SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012 的三節點 Windows Server 容錯移轉叢集 (WSFC) 叢集。如需設定 Windows Server 2012 R2 容錯移轉叢集的資訊和詳細步驟,請參閱<容錯移轉叢集概觀>。Obtain access to or create a three node Windows Server Failover Clustering (WSFC) cluster that you can use to install SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012 on each cluster node. For information and detailed steps to configure a Windows Server 2012 R2 failover cluster, see Failover Clustering Overview.

準備 SQL Server 環境Prepare the SQL Server environment

您必須準備 SQL Server 2014 (SP1) 或 SQL Server 2016 環境,才能建立 SharePoint Server 2016 的可用性群組。Before you can create an Availability Group for SharePoint Server 2016, you must prepare the SQL Server 2014 (SP1) or SQL Server 2016 environment.

當您準備資料庫伺服器環境時,必須考量 SharePoint Server 資料庫需求。安裝 SQL Server 之前,請參閱下列文章:When you prepare the database server environment you must consider SharePoint Server database requirements. Review the following articles before you install SQL Server:

若要準備環境,請完成下列工作:To prepare the environment, complete the following tasks:

  • 安裝 SQL Server 必要條件。Install the SQL Server prerequisites.

  • 安裝 SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012。Install SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012.

  • 啟用 Always On。Enable Always On.

安裝 SQL Server 2014 (SP1)Install SQL Server 2014 (SP1)

請使用下列程序安裝 SQL Server 2014 (SP1)。Use the following procedure to install SQL Server 2014 (SP1).

安裝 SQL Server 2014 (SP1)To install SQL Server 2014 (SP1)

  1. 在每個叢集節點上安裝 SQL Server 2014 (SP1) 必要條件。Install SQL Server 2014 (SP1) prerequisites on each cluster node.

    如需詳細資訊,請參閱安裝 SQL Server 2014 的硬體與軟體需求AlwaysOn 可用性群組的必要條件、限制和建議 (SQL Server)For more information, see Hardware and Software Requirements for Installing SQL Server 2014 and Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server).

  2. 在每個叢集節點上安裝 SQL Server。Install SQL Server on each cluster node.

    如需詳細資訊,請參閱 SQL Server 2014 快速開始安裝安裝 SQL Server 2014 逐步教學課程For more information, see Quick-Start Installation of SQL Server 2014 and Installing SQL Server 2014 Step by Step Tutorial.

安裝 SQL Server 2016Install SQL Server 2016

請使用下列程序安裝 SQL Server 2016。Use the following procedure to install SQL Server 2016.

安裝 SQL Server 2016To install SQL Server 2016

  1. 在每個叢集節點上安裝 SQL Server 2016 必要條件。Install SQL Server 2016 prerequisites on each cluster node.

    如需詳細資訊,請參閱安裝 SQL Server 2016For more information, see Install SQL Server 2016.

  2. 在每個叢集節點上安裝 SQL Server 2016。Install SQL Server 2016 on each cluster node.

    如需詳細資訊,請參閱 SQL Server 容錯移轉叢集安裝For more information, see SQL Server Failover Cluster Installation.

安裝 SQL Server 2012Install SQL Server 2012

若要安裝 SQL Server 2012To install SQL Server 2012

  1. 在每個叢集節點上安裝 SQL Server 2012 的必要條件。Install SQL Server 2012 prerequisites on each cluster node.

    如需詳細資訊,請參閱<AlwaysOn 可用性群組的必要條件、限制和建議 (SQL Server)>。For more information, see Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server).

  2. 在每個叢集節點上安裝 SQL Server。Install SQL Server on each cluster node.

    如需詳細資訊,請參閱<SQL Server 2012 安裝>。For more information, see Installation for SQL Server 2012.

啟用 Always OnEnable Always On

您必須對叢集中的每部資料庫伺服器啟用 Always On。You must enable Always On for each database server in the cluster.

注意

您可以使用 SQL Server Management Studio、Transact-SQL 或 Windows PowerShell 3.0 來啟用 Always On。You can enable Always On by using SQL Server Management Studio, Transact-SQL, or Windows PowerShell 3.0.

啟用 Always OnTo enable Always On

  1. 您的登入帳戶必須具備建立可用性群組的權限等級。該帳戶必須具備 db_owner 固定資料庫角色中的成員資格,以及 AVAILABILITY GROUP 伺服器權限、CONTROL AVAILABILITY GROUP 權限、ALTER ANY AVAILABILITY GROUP 權限或 CONTROL SERVER 權限。Your logon account must have the permission levels to create an availability group. The account must have membership in the db_owner fixed database role and either CREATE AVAILABILITY GROUP server permission, CONTROL AVAILABILITY GROUP permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.

  2. 登入將裝載主要複本的伺服器並啟動 SQL Server 組態管理員。Log on to the server that will host the primary replica and start SQL ServerConfiguration Manager.

  3. 在 [物件總管] 中,選取 [SQL Server 服務]*,以滑鼠右鍵按一下 *SQL Server ((<執行個體名稱>),(其中 <執行個體名稱> 為您想要啟用 Always On 可用性群組的本機伺服器執行個體名稱),然後按一下 [內容]****。In Object Explorer, select SQL Server Services, right-click SQL Server ( ), where is the name of a local server instance for which you want to enable Always On Availability Groups, and then click Properties.

  4. 選取 [AlwaysOn 高可用性]**** 索引標籤。Select the AlwaysOn High Availability tab.

  5. 選取 [啟用 AlwaysOn 可用性群組]**** 核取方塊,然後按一下 [確定]*Select the *Enable AlwaysOn Availability Groups check box, and then click OK.

  6. 即使已儲存變更,您還是必須手動重新啟動 SQL Server 服務 (MSSQLSERVER) 來認可變更。手動重新啟動讓您能夠選擇最符合您業務需求的重新啟動時間。Although the change is saved you must manually restart the SQL Server service (MSSQLSERVER) to commit the change. The manual restart enables you to choose a restart time that is best for your business requirements.

  7. 重複執行上述步驟,在其他叢集節點上啟用適用於 SQL Server 的 Always On。Repeat the previous steps to enable Always On for SQL Server on the other cluster nodes.

如需詳細資訊,請參閱啟用和停用 AlwaysOn 可用性群組 (SQL Server)For more information, see Enable and Disable AlwaysOn Availability Groups (SQL Server).

建立與設定可用性群組Create and configure the availability group

根據您規劃來建立可用性群組的 SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012 2016 環境,您可能必須先建立要使用的暫存資料庫,再建立可用性群組。Depending on the SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012 environment where you plan to create the Availability Group, you might have to create a temporary database to use before you create the Availability Group.

建立可用性群組的程序會要求您為可用性群組提供名稱,然後在連線的伺服器執行個體上選取符合資格的使用者資料庫來作為可用性資料庫。The process that creates an availability group requires you to provide a name for the availability group and then select an eligible user database on the connected server instance as an availability database.

注意

資料庫必須是使用者資料庫,才能將它新增至可用性群組。系統資料庫無法隸屬於可用性群組。如需詳細資訊,請參閱 AlwaysOn 可用性群組的必要條件、限制和建議 (SQL Server) 的<可用性資料庫的必要條件和限制>一節,以及參閱 建立及設定可用性群組 (SQL Server)A database must be a user database in order to add it to an availability group. System databases can't belong to an availability group. For more information, see the "Availability Database Prerequisites and Restrictions" section of Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server) and see Creation and Configuration of Availability Groups (SQL Server).

如果所連線伺服器的執行個體上沒有使用者資料庫 (我們的範例即是如此),則您需要建立使用者資料庫。請使用下列程序建立暫存使用者資料庫,其將是群組的暫存主要複本。If there are no user databases on the instance of the connected server, which is the case in our example, you need to create one. Use the following procedure to create a temporary user database that will be a temporary primary replica for the group.

若要建立暫存的使用者資料庫To create a temporary user database

  1. 確定您的登入帳戶具備執行此工作的正確權限。您在 master 資料庫中需要具備下列其中一個權限,才能建立新的資料庫:Make sure that your logon account has the correct permissions for this task. You require one of the following permissions in the master database to create the new database:

    • CREATE DATABASECREATE DATABASE

    • 建立任何資料庫CREATE ANY DATABASE

    • ALTER ANY DATABASEALTER ANY DATABASE

  2. 登入將裝載主要複本的伺服器,在範例中為 SP-SRV1。Log on to the server that will host the primary replica, which is SP-SRV1 in our example.

  3. 啟動 Management Studio。Start Management Studio.

  4. 在 [物件總管] 中,以滑鼠右鍵按一下 [資料庫]*,然後按一下 [新增資料庫]In Object Explorer, right-click **Databases* and then click New Database.

  5. 在 [新增資料庫] 對話方塊中,輸入 [資料庫名稱:]*,在此範例中為 "TemporaryUserDB"。In the New Database dialog box, type the *Database name:, which is "TemporaryUserDB" for this example.

    由於這是您要在建立可用性群組後刪除的暫存資料庫,因此可以使用預設設定。按一下 [確定]*Because this is a temporary database that you delete after you create the availability group, you can use the default settings. Click *OK.

    因為 [新增可用性群組精靈] 只會在已備份使用者資料庫的情況下建立可用性群組,所以您必須備份該暫存資料庫。Because the New Availability Group Wizard will not create an availability group unless the user database was backed up, you have to back up the temporary database.

  6. 在 [物件總管] 中,展開 [資料庫]*,然後使用滑鼠右鍵按一下您剛建立的暫存資料庫。挑選 [工作],然後選擇 [備份]In Object Explorer expand *Databases and right-click the temporary database that you just created. Pick Tasks and then choose Back Up.

  7. 在 [備份資料庫]**** 對話方塊中,按一下 [確定]**** 以接受所有預設設定並建立備份。In the Back Up Database dialog box, click OK to accept all the default settings and create the back up.

關於複本和資料同步處理About replicas and data synchronization

您應該先熟悉下列關於複本和資料同步處理的資訊,再建立和設定 SharePoint 伺服器陣列的可用性群組。You should be familiar with the following information about replicas and data synchronization before creating and configuring the availability groups for your SharePoint farm.

關於複本About replicas

為每個可用性複本指派一個初始角色 (主要角色或次要角色皆可),該複本的可用性資料庫會繼承此角色。指定的複本角色會判斷它是否要主控讀寫資料庫或唯讀資料庫、容錯移轉的類型,以及它是否要使用同步認可或非同步認可。Every availability replica is assigned an initial role—either the primary role or the secondary role, which the availability databases of that replica inherit. The role of a given replica determines whether it hosts read-write databases or read-only databases, the type of failover and whether it uses synchronous commit or asynchronous commit.

注意

在 SQL Server 2014 和更新版本中,次要複本的最大數目從 4 增加為 8。The maximum number of secondary replicas is increased from 4 to 8 in SQL Server 2014 and later versions.

下表顯示當您第一次建立可用性群組或新增次要複本時,必須針對每個複本提供的資訊。The following table shows the information that you have to provide for each replica, either when you first create the availability group, or when you add secondary replicas.

複本設定需求Replica configuration requirements

複本資訊Replica information 描述Description
伺服器執行個體Server Instance
顯示將裝載可用性複本之伺服器的執行個體名稱。Displays the name of the instance of the server that will host the availability replica.
初始角色Initial Role
指出新複本將先執行的角色:主要或次要。Indicates the role that the new replica will first perform: Primary or Secondary.
自動容錯移轉 (最多 2 個)Automatic Failover (Up to 2)
指出複本使用的容錯移轉類型:自動或手動。Indicates the type of failover that the replica uses: automatic or manual.
同步認可 (最多 3 個)Synchronous Commit (Up to 3)
指出針對複本所使用的認可類型。Indicates the type of commit that is used for the replica.
可讀取次要Readable Secondary
指出是否可讀取次要複本。Indicates whether a secondary replica can be read.
設定選項無法用於讀取存取權、唯讀和唯讀目的。如需詳細資訊,請參閱使用中次要:可讀取的次要複本 (AlwaysOn 可用性群組)設定可用性群組的唯讀路由 (SQL Server)The configuration options are unavailable for read access, read-only, and read-only intent. For more information, see Active Secondaries: Readable Secondary Replicas (AlwaysOn Availability Groups) and Configure Read-Only Access on an Availability Replica (SQL Server).
Note: 在 SQL Server 2014 和更新版本中,中斷與主要複本的連線時或在叢集仲裁遺失期間,可讀取次要複本現在仍然可用於讀取工作負載。Note: In SQL Server 2014 and later, readable secondary replicas now remain available for read workloads when they are disconnected from primary replicas or during cluster quorum loss.

注意

當您將複本新增至群組時,也要為每個複本提供端點,並設定備份喜好設定。如需詳細資訊,請參閱在新增或修改可用性複本時指定端點 URL (SQL Server)使用中次要:在次要複本上備份 (AlwaysOn 可用性群組)When you add replicas to a group, you will also provide the endpoint for each replica and configure backup preferences. For more information, see Specify the Endpoint URL When Adding or Modifying an Availability Replica (SQL Server) and Active Secondaries: Backup on Secondary Replicas (AlwaysOn Availability Groups).

資料同步處理Data synchronization

在進行可用性群組建立程序的過程中,您必須在主要複本上製作資料的相同複本,並在次要複本上安裝該複本。此為可用性群組的初始資料同步處理。如需詳細資訊,請參閱選取初始資料同步處理頁面 (AlwaysOn 可用性群組精靈)As part of the availability group creation process, you have to make an exact copy of the data on the primary replica and install the copy on the secondary replica. This is the initial data synchronization for the Availability Group. For more information, see Select Initial Data Synchronization Page (AlwaysOn Availability Group Wizards).

網路共用必須存在且必須可讓 Always On 設定中的所有節點存取,以便在裝載複本的所有叢集節點之間進行初始資料同步處理。如需詳細資訊,請參閱網路共用延伸檔案和存放服務概觀A network share must exist and must be accessed by all the nodes in the Always On configuration to do the initial data synchronization between all the cluster nodes that host a replica. For more information, see Network Shares Extension and File and Storage Services Overview.

當您使用 [新增可用性群組精靈] 來啟動資料同步處理時,存在著下列限制:The following restrictions exist when you use the New Availability Group wizard to start data synchronization:

  • 如果次要複本位置上的檔案路徑與主要複本位置上的檔案路徑不同,則您必須手動啟動資料同步處理。If the file paths on the secondary replica location differ from the file paths on the primary location, you have to start data synchronization manually.

  • 如果次要複本上存在任何次要資料庫,您必須先手動刪除次要資料庫,才能在「新增可用性群組」中啟動資料同步處理。但是,如果您想要使用現有的次要資料庫,請結束 [新增可用性群組精靈],並手動啟動資料同步處理。If any secondary database exists on a secondary replica, you have to manually delete the secondary databases before you start data synchronization in the New Availability Group. However, if you want to use existing secondary databases, exit the New Availability Group wizard and start data synchronization manually.

  • 若要使用可用性群組精靈來同步處理資料,您必須擁有所有複本均可寫入的備份共用。您可以藉由瀏覽至該共用,或者在 [指定所有複本可存取的共用網路位置]**** 方塊中輸入它的完整通用命名慣例 (UNC) 路徑名稱 \系統名稱\共用名稱\路徑,,來指定共用。To use the availability group wizard to synchronize data, you have to have a backup share that all the replicas can write to. You can specify the share by browsing to it or by entering its fully qualified universal naming convention (UNC) path name, \Systemname\ShareName\Path, in the Specify a shared network location accessible by all replicas box.

針對可用性群組中的每個資料庫,[啟動資料同步處理]**** 頁面會顯示下列作業的進度:For each database in the availability group, the Start Data Synchronization page shows the progress of the following operations:

  • 在網路共用上建立主要資料庫的完整資料庫備份。Creating a full database backup of the primary database on the network share.

  • 將這些備份還原至次要複本位置。Restoring these backups to the secondary replica location.

    這些還原作業會使用 RESTORE WITH NORECOVERY 選項,並將新的次要資料庫保留為 RESTORING 狀態。These restore operations both use RESTORE WITH NORECOVERY option and leave the new secondary database in the RESTORING state.

  • 將次要資料庫加入可用性群組。Joining the secondary database to the availability group.

    此步驟會讓次要資料庫處於 ONLINE 狀態,並針對此資料庫啟動資料同步處理。This step puts the secondary database in the ONLINE state and starts data synchronization for this database.

登入複寫Login replication

使用與舊版 SQL Server 相同的處理方式所建立的 SharePoint 登入不會在可用性群組中進行複寫。會發生此情況的原因在於登入資訊是儲存於 MasterDB 資料庫中,這並不會進行複寫。即使伺服器陣列帳戶是在同步處理複本時所建立,還是無法在容錯移轉後使用登入資訊。SharePoint logins that are created by using the same approach as in previous releases of SQL Server are not replicated in an availability group. This occurs because login information is stored in the MasterDB database, which is not replicated. Although the farm accounts are created when replicas are synchronized, login information is not available after a failover.

如果您已經建立可用性群組並同步處理主要和次要複本,則解決方法是將登入從主要複本手動複製到次要複本。If you have already created an availability group and synchronized the primary and secondary replicas, the workaround is to manually copy the logins from the primary replica to the secondary replicas.

SQL Server 2012 引進「擁有適用於自主資料庫之密碼的使用者」的概念。資料庫本身會儲存所有資料庫中繼資料和使用者資訊,而定義於此資料庫中的使用者不需擁有對應的登入。此資料庫中的資訊是透過可用性群組進行複寫,且可在容錯移轉之後使用。如需詳細資訊,請參閱自主資料庫SQL Server 2012 introduced the concept of Users with Passwords for Contained Databases. The database itself stores all the database metadata and user information, and a user who is defined in this database does not have to have a corresponding login. The information in this database is replicated by the availability group and is available after a failover. For more information, see Contained Databases.

重要

如果您建立新的 SharePoint 登入以用於現有的可用性群組,請務必將該登入新增至自主資料庫,如此系統便會將登入複寫至每個主控 SQL Server 執行個體的伺服器以供可用性群組使用。例如,如果您針對某個 Web 應用程式建立其他應用程式集區,並為其指定新的識別 (您尚未使用的應用程式集區帳戶),則您需要將該帳戶新增為登入。If you create a new SharePoint login to use for an existing availability group, make sure to add the login to the contained database so it is replicated to each server that is hosting a SQL Server instance for the availability group. For example, if you create another application pool for a Web App and give it a new identity (an application pool account that you have not used), then you need to add that account as a login.

建立與設定可用性群組Create and configure the availability group

使用下列程序,在主要複本上建立可用性群組,在範例中為 SP-SRV1。Use the following procedure to create an availability group on the primary replica, which is SP-SRV1 in our example.

建立可用性群組Create the availability group

  1. 確定您的登入帳戶具備必要權限以便建立可用性群組。這項作業要求具備 db_owner 固定資料庫角色中的成員資格,以及 CREATE AVAILABILITY GROUP 伺服器權限、CONTROL AVAILABILITY GROUP 權限、ALTER ANY AVAILABILITY GROUP 權限或 CONTROL SERVER 權限。Make sure that your logon account has the required permissions to create an availability group. This requires membership in the db_owner fixed database role and either CREATE AVAILABILITY GROUP server permission, CONTROL AVAILABILITY GROUP permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.

  2. 登入將裝載主要複本的伺服器並啟動 SQL Server Management Studio。Log on to the server that will host the primary replica and start SQL Server Management Studio.

  3. 若要啟動 [新增可用性群組精靈],可以滑鼠右鍵按一下 [AlwaysOn 高可用性]*,然後按一下 [新增可用性群組精靈]To start the New Availability Group Wizard, right-click **AlwaysOn High Availability* and then click New Availability Group Wizard.

  4. 按 [下一步]**** 以前往 [指定名稱]**** 頁面。在 [可用性群組名稱:]**** 方塊中輸入 SP-AG1 作為新可用性群組的名稱。Click Next to advance to the Specify Name page. Enter SP-AG1 as the name of the new availability group in the Availability group name: box.

    此名稱必須是:有效的 SQL Server 識別碼、在 Windows Server 容錯移轉叢集的叢集上以及在網域上的唯一名稱。This name must be: a valid SQL Server identifier, unique on the Windows Server Failover Clustering cluster and unique on the domain.

  5. 在 [選取資料庫]**** 頁面上,所有符合資格可成為新的可用性群組之主要資料庫的使用者資料庫,都會列在 [這個 SQL Server 執行個體上的使用者資料庫]**** 方格上。選取 [TemporaryUserDB]*,然後按 [下一步]On the **Select Databases* page, all user databases that are eligible to become the primary database for the new availability group are listed on the User databases on this instance of SQL Server grid. Select TemporaryUserDB, and then click Next.

  6. 在 [指定複本]**** 頁面上,使用下列索引標籤來設定適用於 SP-AG1 的複本:[複本]*、[端點]* 及 [備份喜好設定]*On the *Specify Replicas page, use the following tabs to configure the replicas for SP-AG1: Replicas, Endpoints, and Backup Preferences.

  7. 可用性群組接聽程式是一個虛擬網路名稱,能夠為資料庫 (指定的可用性群組) 提供用戶端連線。可用性群組接聽程式會將連入連線導向至主要複本或導向至唯讀的次要複本。接聽程式會在可用性群組容錯移轉後提供快速的應用程式容錯移轉。如需詳細資訊,請參閱可用性群組接聽程式、用戶端連接及應用程式容錯移轉 (SQL Server)An availability group listener is a virtual network name that provides client connectivity to the database a given availability group. Availability group listeners direct incoming connections to the primary replica or to a read-only secondary replica. The listener provides fast application failover after an availability group fails over. For more information, see Availability Group Listeners, Client Connectivity, and Application Failover (SQL Server).

    在 [接聽程式]**** 索引標籤上,設定適用於此範例的可用性群組接聽程式,並使用 AGListener 名稱。On the Listener tab, configure an availability group listener for our example, use the name AGListener.

    重要

    當您使用的可用性群組含有已部署於多重子網路上的複本時,就可能發生間歇性且特別高的延遲。最佳作法是,與多重子網路環境中 SharePoint 可用性群組的連線應該設定 specifyMultiSubnetFailover=True ,以避免因高網路延遲而引發的問題。如需詳細資訊,請參閱 支援可用性群組多重子網路容錯移轉一節。Intermittent, unusually high latency might occur when you use availability groups that have replicas that are deployed on multiple subnets. As a best practice, connections to SharePoint availability groups in a multi-subnet environment should configure specifyMultiSubnetFailover=True to avoid issues caused by high network latency. For more information, see the Supporting Availability Group Multi-Subnet Failovers section.

    您無法直接指定 MultiSubnetFailover=True ,因為 SharePoint 用戶端無法直接修改連線字串。您必須使用 PowerShell,在 MultiSubnetFailover 資料庫屬性上設定此值。下列範例示範如何執行這項操作。You cannot directly specify MultiSubnetFailover=True because a SharePoint client cannot directly modify a connection string. You must use PowerShell to set this value on the MultiSubnetFailover database property. The following example shows how you can do this.

    $dbs = Get-SPDatabase | ?{$_.MultiSubnetFailover -ne $true}
        foreach ($db in $dbs)
        {
             $db.MultiSubnetFailover = $true
              $db.Update()
        }
    
  8. 在 [選取的執行個體]**** 方格中,針對每個執行個體選取所需的設定,然後按 [下一步]*Select the desired configuration for each instance in the *Selected instances grid, and then click Next.

  9. 按一下 [完成]**** 以建立可用性群組。Click Finish to create the availability group.

  10. [選取初始資料同步處理]**** 頁面讓您能夠選取同步處理喜好設定,以及指定所有複本都能存取的共用網路位置。針對我們的環境,請接受預設值 [完整]*,以執行完整的資料庫與記錄備份。按 [下一步]The **Select Initial Data Synchronization* page lets you select a synchronization preference and specify the shared network location that all replicas can access. For our environment accept the default, Full, which performs full database and log backups. Click Next.

  11. 精靈的 [驗證]**** 頁面會先顯示六項檢查結果,然後才會讓您繼續進行可用性群組的建立。如果通過所有檢查,請按 [下一步]**** 繼續。如果有任何測試失敗,則您必須先更正錯誤,然後按一下 [重新執行驗證]**** 再次執行驗證測試之後才能繼續。通過所有測試之後,請按 [下一步]**** 繼續。The Validation page of the wizard displays the results of six checks before it lets you continue with availability group creation. If all checks pass, click Next to continue. If any tests fail, you cannot continue until you correct the error and then click Re-run Validation to run the validation tests again. When all the tests pass, click Next to continue.

  12. 在 [摘要]**** 頁面上,確認您正在新增之複本的設定,然後按一下 [完成]**** 儲存設定。若要變更設定,請按 [上一步]*,以返回先前的精靈頁面。On the *Summary page, verify the configuration of the replica that you are adding and then click Finish to save it. To change the configuration, click Previous to return to previous wizard pages.

安裝及設定 SharePoint ServerInstall and configure SharePoint Server

程序進行到此,您就可以安裝 SharePoint Server 並建立伺服器陣列。請使用下列程式作為安裝與設定 SharePoint Server 的指導。At this point in the process, you can install SharePoint Server and create the farm. Use the following procedure as a guide to install and configure SharePoint Server.

注意

如需詳細的安裝及設定指示,請參閱<安裝 SharePoint Server 2016>和<安裝 SharePoint 2013>。For detailed installation and configuration instructions, see Install SharePoint Server 2016 and Install for SharePoint 2013.

若要安裝 SharePoint ServerTo install SharePoint Server

  1. 將 SharePoint Server 程式檔複製到您規劃安裝 SharePoint 之電腦上的本機磁碟,或者複製到網路檔案共用。Copy the SharePoint Server program files to a local disk on the computer where you plan to install SharePoint or to a network file share.

  2. 執行 Microsoft SharePoint 產品準備工具,安裝設定及使用 SharePoint Server 的所有必要條件。Run the Microsoft SharePoint Products Preparation Tool, to install all the prerequisites to set up and use SharePoint Server.

  3. 執行安裝程式以安裝二進位檔、設定安全性權限,以及編輯 SharePoint Server 的登錄設定。Run Setup to install binaries, configure security permissions, and edit registry settings for SharePoint Server.

  4. 執行 SharePoint 產品設定精靈,以安裝和設定設定資料庫、安裝和設定內容資料庫,以及安裝管理中心。Run the SharePoint Products Configuration Wizard to install and configure the configuration database, install and configure the content database, and install Central Administration.

  5. 在 [指定設定資料庫設定]**** 頁面的 [資料庫伺服器]**** 方塊中,輸入 AGListener 作為正在執行 SQL Server 之電腦的名稱。On the Specify Configuration Database Settings page, in the Database server box, type AGListener as the name of the computer that is running SQLServer_2nd_NoVer.

    重要

    若要提供自動容錯移轉,您必須指定可用性群組接聽程式的名稱作為 SharePoint Server 之資料庫的名稱。To provide automatic failover, you must specify the name of the availability group listener as the name of the database for SharePoint Server.

將 SharePoint 資料庫新增至可用性群組Add SharePoint databases to the availability group

若要完成適用於 SharePoint Server 伺服器陣列的 Always On 設定,請將 SharePoint 資料庫新增至可用性群組,並將次要複本同步處理至主要複本。To finalize setup of Always On for a SharePoint Server farm, add the SharePoint databases to the availability group and synchronize secondary replicas to the primary replica.

重要

只有新增支援的資料庫,才能與 SQL Server Always On 可用性群組搭配使用。如需詳細資訊,請參閱 SharePoint 資料庫支援的高可用性和災害復原選項Only add the databases that are supported for use with a SQL Server Always On Availability Group. For more information, see Supported high availability and disaster recovery options for SharePoint databases

在裝載主要複本的伺服器上,您必須執行 [將資料庫新增至可用性群組精靈],將所有 SharePoint 資料庫新增至可用性群組。下列程序與我們先前描述有關如何建立可用性群組的程序相同。On the server that hosts the primary replica, you have to run the Add Databases to Availability Group wizard to add all the SharePoint databases to the availability group. The following procedure is the same as the procedure that we described earlier about how to create the availability group.

若要將 SharePoint 資料庫新增至可用性群組To add SharePoint databases to the availability group

  1. 登入將裝載主要複本的伺服器並啟動 SQL Server Management Studio。Log on to the server that will host the primary replica and start SQL Server Management Studio.

    您使用的帳戶必須是您安裝 SharePoint Server 之每部伺服器的本機系統管理員群組所屬成員The account that you use must be a member of the Local Administrators group for each server where you install SharePoint Server

    此外,此帳戶至少必須具備下列其中一個權限:In addition, the account must have at least one of the following permissions:

    • 可用性群組的 ALTER AVAILABILITY GROUP 權限ALTER AVAILABILITY GROUP permission on the availability group

    • CONTROL AVAILABILITY GROUP 權限CONTROL AVAILABILITY GROUP permission

    • ALTER ANY AVAILABILITY GROUP 權限ALTER ANY AVAILABILITY GROUP permission

    • CONTROL SERVER 權限CONTROL SERVER permission

    若要將資料庫加入可用性群組,需要具備 db_owner 固定資料庫角色中的成員資格。To join a database to an availability group requires membership in the db_owner fixed database role.

  2. 在 [物件總管] 中,瀏覽至並視需要展開可用性群組。In Object Explorer, browse to, and if it is necessary expand the Availability Groups.

  3. 以滑鼠右鍵按一下範例群組 SP-AG1,然後按一下 [新增資料庫]*Right-click the example group, SP-AG1, and then click *Add Database.

  4. 在 [選取資料庫]**** 頁面上,所有符合資格可成為新的可用性群組之主要資料庫的使用者資料庫,都會列在 [這個 SQL Server 執行個體上的使用者資料庫]**** 方格上。使用核取方塊來選取您要新增至群組的所有資料庫,然後按 [下一步]*On the *Select Databases page, all user databases that are eligible to become the primary database for the new availability group are listed on the User databases on this instance of SQL Server grid. Use the check boxes to select all the databases that you want to add to the group, and then click Next.

  5. [選取初始資料同步處理]**** 頁面讓您能夠選取同步處理喜好設定,以及指定所有複本都能存取的共用網路位置。針對我們的環境,接受預設值 [完整]*,以執行完整的資料庫與記錄備份。按 [下一步]The **Select Initial Data Synchronization* page lets you select a synchronization preference and specify the shared network location that all replicas can access. For our environment we'll accept the default, Full, which performs full database and log backups. Click Next.

  6. 精靈的 [驗證]**** 頁面會先顯示六項檢查結果,然後才會讓您繼續進行可用性群組的建立。如果有任何測試失敗,則您必須先更正錯誤,然後按一下 [重新執行驗證]**** 再次執行驗證測試之後才能繼續。通過所有測試之後,請按 [下一步]**** 繼續。The Validation page of the wizard displays the results of six checks before it lets you continue with availability group creation. If any tests fail, you cannot continue until you correct the error and then click Re-run Validation to run the validation tests again. When all the tests pass, click Next to continue.

  7. 在 [摘要]**** 頁面上,確認您所新增之複本的設定,然後按一下 [完成]**** 保留設定。若要變更設定,請按 [上一步]*,以返回先前的精靈頁面。On the *Summary page, verify the configuration of the replica that you are adding, and then click Finish to keep it. To change the configuration, click Previous to return to previous wizard pages.

重要

您新增至 SharePoint 伺服器陣列的資料庫不會自動新增至可用性群組。您必須使用本文所述的步驟,或使用指令碼使程序自動進行,藉以新增資料庫。Databases that you add to a SharePoint farm are not automatically added to the availability group. You must add them by using the steps described in this article or by using scripts to automate the procedure.

使用容錯移轉測試來驗證 Always On 安裝Use failover tests to validate the Always On installation

當您將 SharePoint 資料與次要複本進行同步處理之後,最後一個步驟便是測試容錯移轉。After you synchronize the SharePoint data with the secondary replicas, the final step is to test failover.

您必須執行大量的容錯移轉測試,以確定 Always On 環境的行為會如預期般運作,以及確保您完全了解與 SQL Server 2014 (SP1)、SQL Server 2016 或 SQL Server 2012 可用性群組相關的設定需求和程序。這些測試包含但不限於下列項目:You must run extensive failover tests to make sure that the behavior of the Always On environment is as expected and that you completely understand the configuration requirements and procedures related to SQL Server 2014 (SP1), SQL Server 2016, or SQL Server 2012 Availability Groups. These tests include but aren't limited to the following:

  • 確認所有的伺服器陣列服務和功能均能完整運作。Verify that all the farm services and features are completely functional.

  • 確認 SharePoint Server 資料已保留且未損毀。Verify that SharePoint Server data is preserved and not corrupted.

使用下列文章中所述的計劃手動容錯移轉或強制手動容錯移轉,來測試可用性群組容錯移轉: Test availability group failover by using either the planned manual failover or the forced manual failover described in the following articles:

SQL Server 2012SQL Server 2012

SQL Server 2014 (SP1)SQL Server 2014 (SP1)

SQL Server 2016SQL Server 2016

您可以使用 SQL Server Management Studio 中的 [容錯移轉精靈]、Transact-SQL 或 SQL Server 2014 (SP1)、SQL Server 2016 和 SQL Server 2012 中的 PowerShell,來執行前述的任一項容錯移轉。You can perform either of the previous failovers by using the Failover Wizard in SQL Server Management Studio, Transact-SQL, or PowerShell in SQL Server 2014 (SP1), SQL Server 2016, and SQL Server 2012.

注意

在「主動-主動」容錯移轉叢集案例中 (其中有多個 SharePoint 執行個體可以彼此進行容錯移轉 ),您必須確定每個伺服器都具有足夠的容量,能夠處理本機工作負載和來自失敗伺服器的工作負載。In an Active-Active failover cluster scenario where there are multiple SharePoint instances can fail over to each other you must ensure that each server has enough capacity to handle the local workload and the workload from the failed server.

監視 Always On 環境Monitor the Always On environment

您必須針對效能、健康情況及容量來監視 Always On 環境。You have to monitor an Always On environment for performance, health, and capacity.

效能Performance

下列新的效能物件可用於監視 Always On 環境。The following new performance objects are available to monitor an Always On environment.

SQL Server 2012SQL Server 2012

SQL Server 2014 (SP1)SQL Server 2014 (SP1)

SQL Server 2016SQL Server 2016

健康情況與容量Health and capacity

針對一般健全狀況監視,您可以使用 [可用性群組儀表板] 取得系統中可用性群組的健全狀況。如需詳細資訊,請參閱<AlwaysOn 可用性群組操作問題適用的 AlwaysOn 原則 (SQL Server) (適用於 SQL Server 2014 (SP1))>和< Always On 原則的操作問題 - Always On 可用性 (適用於 SQL Server 2016)>。如需 SQL Server 2012 的詳細資訊,請參閱下列文章:For general health monitoring you can use the Availability Groups Dashboard to obtain the health of the availability groups in the system. For more information, see AlwaysOn Policies for Operational Issues with AlwaysOn Availability Groups (SQL Server) for SQL Server 2014 (SP1) and Always On Policies for Operational Issues - Always On Availability for SQL Server 2016. For more information about SQL Server 2012, see the following:

您也可以使用 Transact-SQL,以使用 Always On 可用性群組所提供的這組類別目錄和動態管理檢視來監視可用性群組。如需詳細資訊,請參閱<監視可用性群組 (Transact-SQL) (適用於 SQL Server 2014 (SP1))>和< 監視可用性群組 (Transact-SQL) (適用於 SQL Server 2016)>。You can also use Transact-SQL to monitor availability groups by using the set of catalog and dynamic management views that are provided for Always On Availability Groups. For more information, see Monitor Availability Groups (Transact-SQL) for SQL Server 2014 (SP1) and Monitor Availability Groups (Transact-SQL) for SQL Server 2016.

另請參閱See also

概念Concepts

安裝及設定 SharePoint Server 2016Install SharePoint Server

其他資源Other Resources

使用 SQL Server AlwaysOn 可用性群組在 Azure 中部署 SharePoint Server 2016Deploying SharePoint Server 2016 with SQL Server AlwaysOn Availability Groups in Azure