您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

在 Azure 虚拟机上配置 SQL Server 故障转移群集实例Configure SQL Server Failover Cluster Instance on Azure Virtual Machines

本文介绍如何在 Resource Manager 模型中的 Azure 虚拟机上创建 SQL Server 故障转移群集实例 (FCI)。This article explains how to create a SQL Server Failover Cluster Instance (FCI) on Azure virtual machines in Resource Manager model. 此解决方案使用 Windows Server 2016 Datacenter Edition 存储空间直通 (S2D) 作为基于软件的虚拟 SAN,在 Windows 群集中的节点 (Azure VM) 之间同步存储(数据磁盘)。This solution uses Windows Server 2016 Datacenter edition Storage Spaces Direct (S2D) as a software-based virtual SAN that synchronizes the storage (data disks) between the nodes (Azure VMs) in a Windows Cluster. S2D 是 Windows Server 2016 中的新增功能。S2D is new in Windows Server 2016.

下图显示了 Azure 虚拟机上的完整解决方案:The following diagram shows the complete solution on Azure virtual machines:

可用性组

上图显示了:The preceding diagram shows:

  • Windows 故障转移群集中的两个 Azure 虚拟机。Two Azure virtual machines in a Windows Failover Cluster. 位于故障转移群集中的虚拟机也称为群集节点节点When a virtual machine is in a failover cluster it is also called a cluster node, or nodes.

  • 每个虚拟机包含两个或更多个数据磁盘。Each virtual machine has two or more data disks.

  • S2D 同步数据磁盘上的数据,并以存储池的形式提供同步的存储。S2D synchronizes the data on the data disk and presents the synchronized storage as a storage pool.

  • 存储池向故障转移群集提供群集共享卷 (CSV)。The storage pool presents a cluster shared volume (CSV) to the failover cluster.

  • SQL Server FCI 群集角色为数据驱动器使用 CSV。The SQL Server FCI cluster role uses the CSV for the data drives.

  • 用于保存 SQL Server FCI IP 地址的 Azure 负载均衡器。An Azure load balancer to hold the IP address for the SQL Server FCI.

  • Azure 可用性集保存所有资源。An Azure availability set holds all the resources.

    备注

    图中的所有 Azure 资源位于同一资源组中。All Azure resources are in the diagram are in the same resource group.

有关 S2D 的详细信息,请参阅 Windows Server 2016 Datacenter Edition 存储空间直通 (S2D)For details about S2D, see Windows Server 2016 Datacenter edition Storage Spaces Direct (S2D).

S2D 支持两种类型的体系结构 - 聚合与超聚合。S2D supports two types of architectures - converged and hyper-converged. 本文档中所述的体系结构为超聚合。The architecture in this document is hyper-converged. 超融合基础设施将存储放置在承载群集应用程序的相同服务器上。A hyper-converged infrastructure places the storage on the same servers that host the clustered application. 在此体系结构中,存储位于每个 SQL Server FCI 节点上。In this architecture, the storage is on each SQL Server FCI node.

许可与定价Licensing and pricing

在 Azure 虚拟机上,可按即付即用 (PAYG) 方式许可 SQL Server 或自带许可证 (BYOL) VM 映像。On Azure Virtual Machines you can license SQL Server using pay as you go (PAYG) or bring your own license (BYOL) VM images. 选择的映像类型会影响收费方式。The type of image you choose affects how you are charged.

使用 PAYG 许可,Azure 虚拟机上的 SQL Server 的故障转移群集实例 (FCI) 会对 FCI 的所有节点(包括被动节点)收取费用。With PAYG licensing, a failover cluster instance (FCI) of SQL Server on Azure Virtual Machines incurs charges for all nodes of FCI, including the passive nodes. 有关详细信息,请参阅 SQL Server Enterprise 虚拟机定价For more information, see SQL Server Enterprise Virtual Machines Pricing.

与软件保障达成企业协议的客户有权为每个活动节点使用一个免费的被动 FCI 节点。Customers with Enterprise Agreement with Software Assurance have the right to use one free passive FCI node for each active node. 要在 Azure 中利用此优势,请使用 BYOL VM 映像,然后在 FCI 的主动节点和被动节点上使用相同的许可证。To take advantage of this benefit In Azure, use BYOL VM images and then use the same license on both the active and passive nodes of the FCI. 有关详细信息,请参阅企业协议For more information, see Enterprise Agreement.

如需比较 Azure 虚拟机中 SQL Server 的 PAYG 和 BYOL 许可,请参阅 SQL VM 入门To compare PAYG and BYOL licensing for SQL Server on Azure Virtual Machines see Get started with SQL VMs.

有关许可 SQL Server 的完整信息,请参阅定价For complete information about licensing SQL Server, see Pricing.

示例 Azure 模板Example Azure template

可以在 Azure 中基于模板创建整个解决方案。You can create the entire solution in Azure from a template. GitHub Azure 快速入门模板中提供了一个模板示例。An example of a template is available in the GitHub Azure Quickstart Templates. 此示例不是针对任何特定工作负荷设计的,也没有针对任何特定工作负荷进行测试。This example is not designed or tested for any specific workload. 运行该模板可以使用与域连接的 S2D 存储创建 SQL Server FCI。You can run the template to create a SQL Server FCI with S2D storage connected to your domain. 可以评估该模板,并根据用途对其进行修改。You can evaluate the template, and modify it for your purposes.

开始之前Before you begin

在继续下一步之前,需要掌握一些知识并做好一些准备工作。There are a few things you need to know and a couple of things that you need in place before you proceed.

要了解的事项What to know

应该对以下技术有实际的了解:You should have an operational understanding of the following technologies:

一个重要的差别在于,在 Azure IaaS VM 来宾故障转移群集上,我们建议每个服务器(群集节点)使用一个 NIC 和一个子网。One important difference is that on an Azure IaaS VM guest failover cluster, we recommend a single NIC per server (cluster node) and a single subnet. Azure 网络具有物理冗余,这使得在 Azure IaaS VM 来宾群集上不需要额外的 NIC 和子网。Azure networking has physical redundancy which makes additional NICs and subnets unnecessary on an Azure IaaS VM guest cluster. 虽然群集验证报告将发出警告,指出节点只能在单个网络上访问,但在 Azure IaaS VM 来宾故障转移群集上可以安全地忽略此警告。Although the cluster validation report will issue a warning that the nodes are only reachable on a single network, this warning can be safely ignored on Azure IaaS VM guest failover clusters.

另外,应该对以下技术有大致的了解:Additionally, you should have a general understanding of the following technologies:

重要

目前,Azure 上的 SQL Server FCI 不支持 SQL Server IaaS 代理扩展At this time, the SQL Server IaaS Agent Extension is not supported for SQL Server FCI on Azure. 我们建议你从参与 FCI 的 VM 中卸载扩展。We recommend that you uninstall the extension from VMs that participate in the FCI. 此扩展支持自动备份和修补等功能,以及 SQL 的一些门户功能。This extension supports features, such as Automated Backup and Patching and some portal features for SQL. 卸载代理后,这些功能对 SQL VM 不起作用。These features will not work for SQL VMs after the agent is uninstalled.

准备工作What to have

在遵循本文中的说明之前,应事先做好以下准备:Before following the instructions in this article, you should already have:

  • Microsoft Azure 订阅。A Microsoft Azure subscription.
  • Azure 虚拟机上的 Windows 域。A Windows domain on Azure virtual machines.
  • 有权在 Azure 虚拟机中创建对象的帐户。An account with permission to create objects in the Azure virtual machine.
  • 能够为以下组件提供足够 IP 地址空间的 Azure 虚拟网络和子网:An Azure virtual network and subnet with sufficient IP address space for the following components:
    • 两台虚拟机。Both virtual machines.
    • 故障转移群集的 IP 地址。The failover cluster IP address.
    • 每个 FCI 的 IP 地址。An IP address for each FCI.
  • 在 Azure 网络中配置的、指向域控制器的 DNS。DNS configured on the Azure Network, pointing to the domain controllers.

满足这些先决条件后,可继续构建故障转移群集。With these prerequisites in place, you can proceed with building your failover cluster. 第一步是创建虚拟机。The first step is to create the virtual machines.

步骤 1:创建虚拟机Step 1: Create virtual machines

  1. 使用订阅登录到 Azure 门户Log in to the Azure portal with your subscription.

  2. 创建 Azure 可用性集Create an Azure availability set.

    可用性集可将各个容错域和更新域中的虚拟机分组。The availability set groups virtual machines across fault domains and update domains. 可用性集确保应用程序不会受到单一故障点(例如网络交换机或服务器机架电源装置)的影响。The availability set makes sure that your application is not affected by single points of failure, like the network switch or the power unit of a rack of servers.

    如果尚未为虚拟机创建资源组,请在创建 Azure 可用性集时执行该操作。If you have not created the resource group for your virtual machines, do it when you create an Azure availability set. 若要使用 Azure 门户创建可用性集,请执行以下步骤:If you're using the Azure portal to create the availability set, do the following steps:

    • 在 Azure 门户中,单击 + 打开 Azure 市场。In the Azure portal, click + to open the Azure Marketplace. 搜索“可用性集”。 Search for Availability set.
    • 单击“可用性集”。 Click Availability set.
    • 单击“创建”。 Click Create.
    • 在“创建可用性集”边栏选项卡中设置以下值: On the Create availability set blade, set the following values:
      • 名称:可用性集的名称。Name: A name for the availability set.
      • 订阅:Azure 订阅。Subscription: Your Azure subscription.
      • 资源组:如果想要使用现有的组,请单击“使用现有项”并从下拉列表中选择该组。 Resource group: If you want to use an existing group, click Use existing and select the group from the drop-down list. 否则,请选择“新建”并键入组的名称。 Otherwise choose Create New and type a name for the group.
      • 位置:设置要在其中创建虚拟机的位置。Location: Set the location where you plan to create your virtual machines.
      • 容错域:使用默认值 (3)。Fault domains: Use the default (3).
      • 更新域:使用默认值 (5)。Update domains: Use the default (5).
    • 单击“创建”创建可用性集。 Click Create to create the availability set.
  3. 在可用性集中创建虚拟机。Create the virtual machines in the availability set.

    在 Azure 可用性集中预配两个 SQL Server 虚拟机。Provision two SQL Server virtual machines in the Azure availability set. 有关说明,请参阅在 Azure 门户中预配 SQL Server 虚拟机For instructions, see Provision a SQL Server virtual machine in the Azure portal.

    将两个虚拟机放在以下位置:Place both virtual machines:

    • 可用性集所在的同一个 Azure 资源组中。In the same Azure resource group that your availability set is in.

    • 域控制器所在的同一个网络中。On the same network as your domain controller.

    • 能够为两个虚拟机提供足够 IP 地址空间的子网中,以及最终可能要在此群集上使用的所有 FCI 中。On a subnet with sufficient IP address space for both virtual machines, and all FCIs that you may eventually use on this cluster.

    • Azure 可用性集中。In the Azure availability set.

      重要

      创建虚拟机后无法设置或更改可用性集。You cannot set or change availability set after a virtual machine has been created.

    从 Azure 市场中选择一个映像。Choose an image from the Azure Marketplace. 可以使用同时包含 Windows Server 和 SQL Server 或者只包含 Windows Server 的市场映像。You can use a Marketplace image with that includes Windows Server and SQL Server, or just the Windows Server. 有关详细信息,请参阅 Azure 虚拟机上的 SQL Server 概述For details, see Overview of SQL Server on Azure Virtual Machines

    Azure 库中的正式 SQL Server 映像包含已安装的 SQL Server 实例,以及 SQL Server 安装软件和所需的密钥。The official SQL Server images in the Azure Gallery include an installed SQL Server instance, plus the SQL Server installation software, and the required key.

    根据 SQL Server 许可证的付费方式选择正确的映像:Choose the right image according to how you want to pay for the SQL Server license:

    • 按使用量付费许可方式:这些映像的每秒费用包括 SQL Server 许可费:Pay per usage licensing: The per-second cost of these images includes the SQL Server licensing:

      • Windows Server Datacenter 2016 上的 SQL Server 2016 EnterpriseSQL Server 2016 Enterprise on Windows Server Datacenter 2016
      • Windows Server Datacenter 2016 上的 SQL Server 2016 StandardSQL Server 2016 Standard on Windows Server Datacenter 2016
      • Windows Server Datacenter 2016 上的 SQL Server 2016 DeveloperSQL Server 2016 Developer on Windows Server Datacenter 2016
    • 自带许可 (BYOL)Bring-your-own-license (BYOL)

      • {BYOL} Windows Server Datacenter 2016 上的 SQL Server 2016 Enterprise{BYOL} SQL Server 2016 Enterprise on Windows Server Datacenter 2016
      • {BYOL} Windows Server Datacenter 2016 上的 SQL Server 2016 Standard{BYOL} SQL Server 2016 Standard on Windows Server Datacenter 2016

    重要

    创建虚拟机后,删除预装的独立 SQL Server 实例。After you create the virtual machine, remove the pre-installed standalone SQL Server instance. 配置故障转移群集和 S2D 之后,将使用预装的 SQL Server 媒体创建 SQL Server FCI。You will use the pre-installed SQL Server media to create the SQL Server FCI after you configure the failover cluster and S2D.

    或者,可以使用只包含操作系统的 Azure 市场映像。Alternatively, you can use Azure Marketplace images with just the operating system. 选择一个 Windows Server 2016 Datacenter 映像,并在配置故障转移群集和 S2D 后安装 SQL Server FCI。Choose a Windows Server 2016 Datacenter image and install the SQL Server FCI after you configure the failover cluster and S2D. 此映像不包含 SQL Server 安装媒体。This image does not contain SQL Server installation media. 将安装媒体放在可以针对每个服务器运行 SQL Server 安装的位置。Place the installation media in a location where you can run the SQL Server installation for each server.

  4. Azure 在创建虚拟机之后,将使用 RDP 连接到每个虚拟机。After Azure creates your virtual machines, connect to each virtual machine with RDP.

    首次使用 RDP 连接到虚拟机时,计算机将询问是否允许在网络上发现此 PC。When you first connect to a virtual machine with RDP, the computer asks if you want to allow this PC to be discoverable on the network. 单击 “是”Click Yes.

  5. 如果使用某个基于 SQL Server 的虚拟机映像,请删除 SQL Server 实例。If you are using one of the SQL Server-based virtual machine images, remove the SQL Server instance.

    • 在“程序和功能”中,右键单击“Microsoft SQL Server 2016 (64 位)”,并单击“卸载/更改”。 In Programs and Features, right-click Microsoft SQL Server 2016 (64-bit) and click Uninstall/Change.

    • 单击“删除”。 Click Remove.

    • 选择默认实例。Select the default instance.

    • 删除“数据库引擎服务”下的所有功能。 Remove all features under Database Engine Services. 不要删除“共享功能”。 Do not remove Shared Features. 参阅下图:See the following picture:

      删除功能

    • 单击“下一步”,并单击“删除”。 Click Next, and then click Remove.

  6. 打开防火墙端口。Open the firewall ports.

    在每个虚拟机上的 Windows 防火墙中打开以下端口。On each virtual machine, open the following ports on the Windows Firewall.

    用途Purpose TCP 端口TCP Port 说明Notes
    SQL ServerSQL Server 14331433 SQL Server 的默认实例正常使用的端口。Normal port for default instances of SQL Server. 如果使用了库中的某个映像,此端口会自动打开。If you used an image from the gallery, this port is automatically opened.
    运行状况探测Health probe 5999959999 任何打开的 TCP 端口。Any open TCP port. 在后面的步骤中,需要将负载均衡器运行状况探测和群集配置为使用此端口。In a later step, configure the load balancer health probe and the cluster to use this port.
  7. 将存储添加到虚拟机。Add storage to the virtual machine. 有关详细信息,请参阅添加存储For detailed information, see add storage.

    这两个虚拟机至少需要两个数据磁盘。Both virtual machines need at least two data disks.

    附加原始磁盘 - 非 NTFS 格式化磁盘。Attach raw disks - not NTFS formatted disks.

    备注

    如果附加 NTFS 格式化的磁盘,只能启用不带磁盘合格性检查的 S2D。If you attach NTFS-formatted disks, you can only enable S2D with no disk eligibility check.

    将至少两个高级 SSD 附加到每个 VM。Attach a minimum of two premium SSDs to each VM. 建议至少附加 P30 (1 TB) 磁盘。We recommend at least P30 (1 TB) disks.

    将主机缓存设置为“只读”。 Set host caching to Read-only.

    在生产环境中使用的存储容量取决于工作负荷。The storage capacity you use in production environments depends on your workload. 本文中所述的值适用于演示和测试。The values described in this article are for demonstration and testing.

  8. 将虚拟机添加到现有的域Add the virtual machines to your pre-existing domain.

创建并配置虚拟机后,可配置故障转移群集。After the virtual machines are created and configured, you can configure the failover cluster.

步骤 2:使用 S2D 配置 Windows 故障转移群集Step 2: Configure the Windows Failover Cluster with S2D

下一步是使用 S2D 配置故障转移群集。The next step is to configure the failover cluster with S2D. 此步骤包括以下子步骤:In this step, you will do the following substeps:

  1. 添加 Windows 故障转移群集功能Add Windows Failover Clustering feature
  2. 验证群集Validate the cluster
  3. 创建故障转移群集Create the failover cluster
  4. 创建云见证Create the cloud witness
  5. 添加存储Add storage

添加 Windows 故障转移群集功能Add Windows Failover Clustering feature

  1. 若要开始,请使用属于本地管理员的成员并且有权在 Active Directory 中创建对象的域帐户,通过 RDP 连接到第一个虚拟机。To begin, connect to the first virtual machine with RDP using a domain account that is a member of local administrators, and has permissions to create objects in Active Directory. 使用此帐户完成余下的配置。Use this account for the rest of the configuration.

  2. 将故障转移群集功能添加到每个虚拟机Add Failover Clustering feature to each virtual machine.

    若要通过 UI 安装故障转移群集功能,请在两个虚拟机上执行以下步骤。To install Failover Clustering feature from the UI, do the following steps on both virtual machines.

    • 单击“服务器管理器”中单击“管理”,并单击“添加角色和功能”。 In Server Manager, click Manage, and then click Add Roles and Features.
    • 在“添加角色和功能向导”中,单击“下一步”,直到出现“选择功能”。 In Add Roles and Features Wizard, click Next until you get to Select Features.
    • 在“选择功能”中,单击“故障转移群集”。 In Select Features, click Failover Clustering. 请包含所有所需的功能和管理工具。Include all required features and the management tools. 单击“添加功能”。 Click Add Features.
    • 单击“下一步” ,然后单击“完成” 安装这些功能。Click Next and then click Finish to install the features.

    若要使用 PowerShell 安装故障转移群集功能,请在某个虚拟机上通过管理员 PowerShell 会话运行以下脚本。To install the Failover Clustering feature with PowerShell, run the following script from an administrator PowerShell session on one of the virtual machines.

    $nodes = ("<node1>","<node2>")
    Invoke-Command  $nodes {Install-WindowsFeature Failover-Clustering -IncludeAllSubFeature -IncludeManagementTools}
    

特此指出,后续步骤遵循了Windows Server 2016 中使用存储空间直通的超聚合解决方案中“步骤 3”下面的说明。For reference, the next steps follow the instructions under Step 3 of Hyper-converged solution using Storage Spaces Direct in Windows Server 2016.

验证群集Validate the cluster

本指南参考了验证群集中的说明。This guide refers to instructions under validate cluster.

使用 UI 或 PowerShell 验证群集。Validate the cluster in the UI or with PowerShell.

若要使用 UI 验证群集,请在某个虚拟机中执行以下步骤。To validate the cluster with the UI, do the following steps from one of the virtual machines.

  1. 在“服务器管理器”中单击“工具”,并单击“故障转移群集管理器”。 In Server Manager, click Tools, then click Failover Cluster Manager.

  2. 在“故障转移群集管理器”中单击“操作”,并单击“验证配置...”。 In Failover Cluster Manager, click Action, then click Validate Configuration....

  3. 单击“资源组名称” 的 Azure 数据工厂。Click Next.

  4. 在“选择服务器或群集”中,键入两个虚拟机的名称。 On Select Servers or a Cluster, type the name of both virtual machines.

  5. 在“测试选项”中,选择“仅运行选择的测试”。 On Testing options, choose Run only tests I select. 单击“下一步” 。Click Next.

  6. 在“测试选择”中,包含除“存储”以外的所有测试。 On Test selection, include all tests except Storage. 参阅下图:See the following picture:

    验证测试

  7. 单击“下一步” 。Click Next.

  8. 在“确认”中,单击“下一步”。 On Confirmation, click Next.

“验证配置向导”将运行验证测试。 The Validate a Configuration Wizard runs the validation tests.

若要使用 PowerShell 验证群集,请在某个虚拟机上通过管理员 PowerShell 会话运行以下脚本。To validate the cluster with PowerShell, run the following script from an administrator PowerShell session on one of the virtual machines.

Test-Cluster –Node ("<node1>","<node2>") –Include "Storage Spaces Direct", "Inventory", "Network", "System Configuration"

验证群集后,创建故障转移群集。After you validate the cluster, create the failover cluster.

创建故障转移群集Create the failover cluster

本指南参考了创建故障转移群集This guide refers to Create the failover cluster.

若要创建故障转移群集,需要:To create the failover cluster, you need:

  • 成为群集节点的虚拟机的名称。The names of the virtual machines that become the cluster nodes.
  • 故障转移群集的名称A name for the failover cluster
  • 故障转移群集的 IP 地址。An IP address for the failover cluster. 可以使用群集节点所在的同一 Azure 虚拟网络和子网中未使用的 IP 地址。You can use an IP address that is not used on the same Azure virtual network and subnet as the cluster nodes.

以下 PowerShell 可创建故障转移群集。The following PowerShell creates a failover cluster. 使用节点的名称(虚拟机名称)以及 Azure VNET 中可用的 IP 地址更新脚本:Update the script with the names of the nodes (the virtual machine names) and an available IP address from the Azure VNET:

New-Cluster -Name <FailoverCluster-Name> -Node ("<node1>","<node2>") –StaticAddress <n.n.n.n> -NoStorage

创建云见证Create a cloud witness

云见证是 Azure 存储 Blob 中存储的新型群集仲裁见证。Cloud Witness is a new type of cluster quorum witness stored in an Azure Storage Blob. 使用云见证就无需单独使用一个 VM 来托管见证共享。This removes the need of a separate VM hosting a witness share.

  1. 为故障转移群集创建云见证Create a cloud witness for the failover cluster.

  2. 创建 Blob 容器。Create a blob container.

  3. 保存访问密钥和容器 URL。Save the access keys and the container URL.

  4. 配置故障转移群集仲裁见证。Configure the failover cluster quorum witness. 请参阅在用户界面中配置仲裁见证See, Configure the quorum witness in the user interface in the UI.

添加存储Add storage

S2D 的磁盘需是空的,不包含分区或其他数据。The disks for S2D need to be empty and without partitions or other data. 若要清除磁盘,请遵循此指南中的步骤To clean disks follow the steps in this guide.

  1. 启用存储空间直通 (S2D)Enable Store Spaces Direct (S2D).

    以下 PowerShell 可启用存储空间直通。The following PowerShell enables storage spaces direct.

    Enable-ClusterS2D
    

    现在,“故障转移群集管理器”中会显示存储池。 In Failover Cluster Manager, you can now see the storage pool.

  2. 创建卷Create a volume.

    S2D 中的某个功能可自动创建存储池(如果已启用此功能)。One of the features of S2D is that it automatically creates a storage pool when you enable it. 接下来,可以创建卷。You are now ready to create a volume. PowerShell cmdlet New-Volume 可自动完成卷的创建过程,包括格式化、添加到群集,以及创建群集共享卷 (CSV)。The PowerShell commandlet New-Volume automates the volume creation process, including formatting, adding to the cluster, and creating a cluster shared volume (CSV). 以下示例创建一个 800 千兆字节 (GB) 的 CSV。The following example creates an 800 gigabyte (GB) CSV.

    New-Volume -StoragePoolFriendlyName S2D* -FriendlyName VDisk01 -FileSystem CSVFS_REFS -Size 800GB
    

    完成此命令后,800 GB 卷将装载为群集资源。After this command completes, an 800 GB volume is mounted as a cluster resource. 该卷位于 C:\ClusterStorage\Volume1\The volume is at C:\ClusterStorage\Volume1\.

    下图显示了包含 S2D 的群集共享卷:The following diagram shows a cluster shared volume with S2D:

    ClusterSharedVolume

步骤 3:测试故障转移群集故障转移Step 3: Test failover cluster failover

在故障转移群集管理器中,验证是否可将存储资源移到另一个群集节点。In Failover Cluster Manager, verify that you can move the storage resource to the other cluster node. 如果可使用故障转移群集管理器连接到故障转移群集并可在两个不同的节点之间移动存储,则可以配置 FCI。If you can connect to the failover cluster with Failover Cluster Manager and move the storage from one node to the other, you are ready to configure the FCI.

步骤 4:创建 SQL Server FCIStep 4: Create SQL Server FCI

配置故障转移群集和所有群集组件(包括存储)后,可创建 SQL Server FCI。After you have configured the failover cluster and all cluster components including storage, you can create the SQL Server FCI.

  1. 使用 RDP 连接到第一个虚拟机。Connect to the first virtual machine with RDP.

  2. 在“故障转移群集管理器”中,确保所有群集核心资源位于第一个虚拟机上。 In Failover Cluster Manager, make sure all cluster core resources are on the first virtual machine. 如有必要,请将所有资源移到此虚拟机。If necessary, move all resources to this virtual machine.

  3. 找到安装媒体。Locate the installation media. 如果虚拟机使用某个 Azure 市场映像,该媒体将位于 C:\SQLServer_<version number>_FullIf the virtual machine uses one of the Azure Marketplace images, the media is located at C:\SQLServer_<version number>_Full. 单击“设置” 。Click Setup.

  4. 在“SQL Server 安装中心”中单击“安装”。 In the SQL Server Installation Center, click Installation.

  5. 单击“新建 SQL Server 故障转移群集安装”。 Click New SQL Server failover cluster installation. 遵照向导中的说明安装 SQL Server FCI。Follow the instructions in the wizard to install the SQL Server FCI.

    FCI 数据目录需位于群集存储中。The FCI data directories need to be on clustered storage. 使用 S2D 时,该存储不是共享磁盘,而是每个服务器上的卷的装入点。With S2D, it's not a shared disk, but a mount point to a volume on each server. S2D 会在两个节点之间同步该卷。S2D synchronizes the volume between both nodes. 该卷以群集共享卷的形式提供给群集。The volume is presented to the cluster as a cluster shared volume. 使用数据目录的 CSV 装入点。Use the CSV mount point for the data directories.

    DataDirectories

  6. 完成向导中的操作后,安装程序会在第一个节点上安装 SQL Server FCI。After you complete the wizard, Setup will install a SQL Server FCI on the first node.

  7. 安装程序在第一个节点上成功安装 FCI 后,请使用 RDP 连接到第二个节点。After Setup successfully installs the FCI on the first node, connect to the second node with RDP.

  8. 打开“SQL Server 安装中心”。 Open the SQL Server Installation Center. 单击“安装”。 Click Installation.

  9. 单击“将节点添加到 SQL Server 故障转移群集”。 Click Add node to a SQL Server failover cluster. 遵照向导中的说明安装 SQL Server 并将此服务器添加到 FCI。Follow the instructions in the wizard to install SQL server and add this server to the FCI.

    备注

    如果使用了包含 SQL Server 的 Azure 市场库映像,该映像已随附 SQL Server 工具。If you used an Azure Marketplace gallery image with SQL Server, SQL Server tools were included with the image. 如果未使用此映像,需单独安装 SQL Server 工具。If you did not use this image, install the SQL Server tools separately. 请参阅 Download SQL Server Management Studio (SSMS)(下载 SQL Server Management Studio (SSMS))。See Download SQL Server Management Studio (SSMS).

步骤 5:创建 Azure 负载均衡器Step 5: Create Azure load balancer

在 Azure 虚拟机上,群集使用负载均衡器来保存每次都需要位于一个群集节点上的 IP 地址。On Azure virtual machines, clusters use a load balancer to hold an IP address that needs to be on one cluster node at a time. 在此解决方案中,负载均衡器保存 SQL Server FCI 的 IP 地址。In this solution, the load balancer holds the IP address for the SQL Server FCI.

创建并配置 Azure 负载均衡器Create and configure an Azure load balancer.

在 Azure 门户中创建负载均衡器Create the load balancer in the Azure portal

若要创建负载均衡器,请执行以下操作:To create the load balancer:

  1. 在 Azure 门户中,转到虚拟机所在的资源组。In the Azure portal, go to the Resource Group with the virtual machines.

  2. 单击“+ 添加”。 Click + Add. 在市场中搜索“负载均衡器”。 Search the Marketplace for Load Balancer. 单击“负载均衡器”。 Click Load Balancer.

  3. 单击“创建”。 Click Create.

  4. 为负载均衡器配置以下属性:Configure the load balancer with:

    • 名称:标识负载均衡器的名称。Name: A name that identifies the load balancer.
    • 类型:负载均衡器可以是公共或专用的。Type: The load balancer can be either public or private. 专用负载均衡器可从同一 VNET 内部访问。A private load balancer can be accessed from within the same VNET. 大多数 Azure 应用程序可以使用专用负载均衡器。Most Azure applications can use a private load balancer. 如果应用程序需要通过 Internet 直接访问 SQL Server,请使用公共负载均衡器。If your application needs access to SQL Server directly over the Internet, use a public load balancer.
    • 虚拟网络:虚拟机所在的同一网络。Virtual Network: The same network as the virtual machines.
    • 子网:虚拟机所在的同一子网。Subnet: The same subnet as the virtual machines.
    • 专用 IP 地址:分配给 SQL Server FCI 群集网络资源的同一 IP 地址。Private IP address: The same IP address that you assigned to the SQL Server FCI cluster network resource.
    • 订阅:Azure 订阅。subscription: Your Azure subscription.
    • 资源组:使用虚拟机所在的同一资源组。Resource Group: Use the same resource group as your virtual machines.
    • 位置:使用虚拟机所在的同一 Azure 位置。Location: Use the same Azure location as your virtual machines. 参阅下图:See the following picture:

    CreateLoadBalancer

配置负载均衡器后端池Configure the load balancer backend pool

  1. 返回到虚拟机所在的 Azure 资源组,找到新的负载均衡器。Return to the Azure Resource Group with the virtual machines and locate the new load balancer. 可能需要在资源组中刷新视图。You may have to refresh the view on the Resource Group. 单击该负载均衡器。Click the load balancer.

  2. 单击“后端池” 并单击“+ 添加” 来添加后端池。Click Backend pools and click + Add to add a backend pool.

  3. 将该后端池与包含 VM 的可用性集进行关联。Associate the backend pool with the availability set that contains the VMs.

  4. 在“目标网络 IP 配置” 下,选中“虚拟机” 并选择将作为群集节点参与操作的虚拟机。Under Target network IP configurations, check VIRTUAL MACHINE and choose the virtual machines that will participate as cluster nodes. 请务必包括将承载 FCI 的所有虚拟机。Be sure to include all virtual machines that will host the FCI.

  5. 单击“确定” 创建后端池。Click OK to create the backend pool.

配置负载均衡器运行状况探测Configure a load balancer health probe

  1. 在负载均衡器边栏选项卡中,单击“运行状况探测”。 On the load balancer blade, click Health probes.

  2. 单击“+ 添加”。 Click + Add.

  3. 在“添加运行状况探测”边栏选项卡中,设置运行状况探测参数: On the Add health probe blade, Set the health probe parameters:

    • 名称:运行状况探测的名称。Name: A name for the health probe.
    • 协议:TCP。Protocol: TCP.
    • 端口:设置为你在此步骤中在防火墙中为运行状况探测创建的端口。Port: Set to the port you created in the firewall for the health probe in this step. 在本文中,示例使用了 TCP 端口 59999In this article, the example uses TCP port 59999.
    • 时间间隔:5 秒。Interval: 5 Seconds.
    • 不正常阈值:2 次连续失败。Unhealthy threshold: 2 consecutive failures.
  4. 单击“确定”。Click OK.

设置负载均衡规则Set load balancing rules

  1. 在负载均衡器边栏选项卡中,单击“负载均衡规则”。 On the load balancer blade, click Load balancing rules.

  2. 单击“+ 添加”。 Click + Add.

  3. 设置负载均衡规则参数:Set the load balancing rules parameters:

    • 名称:负载均衡规则的名称。Name: A name for the load balancing rules.
    • 前端 IP 地址:使用 SQL Server FCI 群集网络资源的 IP 地址。Frontend IP address: Use the IP address for the SQL Server FCI cluster network resource.
    • 端口:设置为 SQL Server FCI TCP 端口。Port: Set for the SQL Server FCI TCP port. 默认实例端口为 1433。The default instance port is 1433.
    • 后端端口:此值使用的端口与启用“浮动 IP (直接服务器返回)”时使用的“端口”值相同。 Backend port: This value uses the same port as the Port value when you enable Floating IP (direct server return).
    • 后端池:使用前面配置的后端池名称。Backend pool: Use the backend pool name that you configured earlier.
    • 运行状况探测:使用前面配置的运行状况探测。Health probe: Use the health probe that you configured earlier.
    • 会话持久性:无。Session persistence: None.
    • 空闲超时(分钟) :4.Idle timeout (minutes): 4.
    • 浮动 IP (直接服务器返回) :EnabledFloating IP (direct server return): Enabled
  4. 单击 “确定”Click OK.

步骤 6:为探测配置群集Step 6: Configure cluster for probe

在 PowerShell 中设置群集探测端口参数。Set the cluster probe port parameter in PowerShell.

若要设置群集探测端口参数,请使用环境中的值更新以下脚本中的变量。To set the cluster probe port parameter, update variables in the following script with values from your environment. 从脚本中删除尖括号 <>Remove the angle brackets <> from the script.

$ClusterNetworkName = "<Cluster Network Name>"
$IPResourceName = "<SQL Server FCI IP Address Resource Name>" 
$ILBIP = "<n.n.n.n>" 
[int]$ProbePort = <nnnnn>

Import-Module FailoverClusters

Get-ClusterResource $IPResourceName | Set-ClusterParameter -Multiple @{"Address"="$ILBIP";"ProbePort"=$ProbePort;"SubnetMask"="255.255.255.255";"Network"="$ClusterNetworkName";"EnableDhcp"=0}

在前面的脚本中,设置环境的值。In the preceding script, set the values for your environment. 以下列表对这些值进行了说明:The following list describes the values:

  • <Cluster Network Name>:Windows Server 故障转移群集的网络名称。<Cluster Network Name>: Windows Server Failover Cluster name for the network. 在“故障转移群集管理器” > “网络” 中,右键单击网络,然后单击“属性” 。In Failover Cluster Manager > Networks, right-click on the network and click Properties. 正确的值位于“常规” 选项卡的“名称” 下。The correct value is under Name on the General tab.

  • <SQL Server FCI IP Address Resource Name>:SQL Server FCI IP 地址资源名称。<SQL Server FCI IP Address Resource Name>: SQL Server FCI IP address resource name. 在“故障转移群集管理器” > “角色” 中,SQL Server FCI 角色的“服务器名称” 下,右键单击 IP 地址资源,然后单击“属性” 。In Failover Cluster Manager > Roles, under the SQL Server FCI role, under Server Name, right click the IP address resource, and click Properties. 正确的值位于“常规” 选项卡的“名称” 下。The correct value is under Name on the General tab.

  • <ILBIP>:ILB IP 地址。<ILBIP>: The ILB IP address. 在 Azure 门户中将此地址配置为 ILB 前端地址。This address is configured in the Azure portal as the ILB front-end address. 这也是 SQL Server FCI IP 地址。This is also the SQL Server FCI IP address. 可在“故障转移群集管理器” 中找到该地址,它与 <SQL Server FCI IP Address Resource Name> 位于同一属性页。You can find it in Failover Cluster Manager on the same properties page where you located the <SQL Server FCI IP Address Resource Name>.

  • <nnnnn>:这是在负载均衡器运行状况探测中配置的探测端口。<nnnnn>: Is the probe port you configured in the load balancer health probe. 任何未使用的 TCP 端口都有效。Any unused TCP port is valid.

重要

群集参数的子网掩码必须是 TCP IP 广播地址:255.255.255.255The subnet mask for the cluster parameter must be the TCP IP broadcast address: 255.255.255.255.

设置群集探测后,可在 PowerShell 中看到所有群集参数。After you set the cluster probe you can see all of the cluster parameters in PowerShell. 运行以下脚本:Run the following script:

Get-ClusterResource $IPResourceName | Get-ClusterParameter 

步骤 7:测试 FCI 故障转移Step 7: Test FCI failover

测试 FCI 的故障转移以验证群集功能。Test failover of the FCI to validate cluster functionality. 请执行以下步骤:Do the following steps:

  1. 使用 RDP 连接到 SQL Server FCI 群集节点之一。Connect to one of the SQL Server FCI cluster nodes with RDP.

  2. 打开“故障转移群集管理器”。 Open Failover Cluster Manager. 单击“角色”。 Click Roles. 观察哪个节点拥有 SQL Server FCI 角色。Notice which node owns the SQL Server FCI role.

  3. 右键单击“SQL Server FCI”角色。Right-click the SQL Server FCI role.

  4. 单击“移动”,并单击“最佳节点”。 Click Move and click Best Possible Node.

“故障转移群集管理器”会显示该角色及其资源已脱机。 Failover Cluster Manager shows the role and its resources go offline. 然后资源会移动,并在另一个节点上联机。The resources then move and come online on the other node.

测试连接Test connectivity

若要测试连接,请登录到同一虚拟网络中的另一个虚拟机。To test connectivity, log in to another virtual machine in the same virtual network. 打开“SQL Server Management Studio”并连接到 SQL Server FCI 名称。 Open SQL Server Management Studio and connect to the SQL Server FCI name.

备注

如果需要,可以下载 SQL Server Management StudioIf necessary, you can download SQL Server Management Studio.

限制Limitations

Azure 虚拟机支持 Windows Server 2019 上的 Microsoft 分布式事务处理协调器 (MSDTC),其中存储位于群集共享卷 (CSV) 和标准负载均衡器上。Azure Virtual Machines support Microsoft Distributed Transaction Coordinator (MSDTC) on Windows Server 2019 with storage on clustered shared volumes (CSV) and a standard load balancer.

在 Azure 虚拟机上,Windows Server 2016 及更早版本不支持 MSDTC,因为:On Azure virtual machines, MSDTC is not supported on Windows Server 2016 and earlier because:

  • 无法将群集 MSDTC 资源配置为使用共享存储。The clustered MSDTC resource cannot be configured to use shared storage. 对于 Windows Server 2016,如果创建 MSDTC 资源,即使存储存在,也不会显示任何可用的共享存储。With Windows Server 2016 if you create an MSDTC resource, it will not show any shared storage available for use, even if the storage is there. Windows Server 2019 中已修复此问题。This issue has been fixed in Windows Server 2019.
  • 基本负载均衡器不处理 RPC 端口。The basic load balancer does not handle RPC ports.

请参阅See Also

Setup S2D with remote desktop (Azure)(使用远程桌面设置 S2D (Azure))Setup S2D with remote desktop (Azure)

Hyper-converged solution with storage spaces direct(包含存储空间直通的超聚合解决方案)Hyper-converged solution with storage spaces direct.

Storage Space Direct Overview(存储空间直通概述)Storage Space Direct Overview

SQL Server support for S2D(S2D 的 SQL Server 支持)SQL Server support for S2D