在 Azure 虚拟机上配置 SQL Server 故障转移群集实例Configure a SQL Server failover cluster instance on Azure virtual Machines

适用于:是Azure VM 上的 SQL ServerAPPLIES TO: yesSQL Server on Azure VM

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

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

完整解决方案

此图显示:This diagram shows:

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

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

  • 存储空间直通同步数据磁盘上的数据,并以存储池的形式提供同步的存储。Storage Spaces Direct synchronizes the data on the data disks 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 in the diagram are in the same resource group.

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

存储空间直通支持两种类型的体系结构:融合与超融合。Storage Spaces Direct 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 虚拟机上,可以使用标准预付费套餐针对 SQL Server 授予许可,也可以使用自带许可 (BYOL) VM 映像。On Azure Virtual Machines, you can license SQL Server using Standard Pay-in-Advance Offer (Standard Pay-in-Advance Offer) or bring-your-own-license (BYOL) VM images. 选择的映像类型会影响收费方式。The type of image you choose affects how you're charged.

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

如果你已签署附带软件保障的企业协议,则可为每个活动节点使用一个免费的被动 FCI 节点。If you have Enterprise Agreement with Software Assurance, you can 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 use the same license on both the active and passive nodes of the FCI. 有关详细信息,请参阅企业协议For more information, see Enterprise Agreement.

如需比较 Azure 虚拟机中 SQL Server 的标准预付费套餐和 BYOL 许可,请参阅 SQL Server VM 入门To compare Standard Pay-in-Advance Offer and BYOL licensing for SQL Server on Azure Virtual Machines, see Get started with SQL Server VMs.

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

示例 Azure 模板Example Azure template

可以在 Azure 中基于模板创建整个解决方案。You can create this entire solution in Azure from a template. GitHub Azure 快速入门模板中提供了一个模板示例。An example of a template is available in the GitHub Azure Quickstart Templates. 此示例不是针对任何特定工作负荷设计的,也没有针对任何特定工作负荷进行测试。This example isn't designed or tested for any specific workload. 运行该模板可以使用与域连接的存储空间直通存储创建 SQL Server FCI。You can run the template to create a SQL Server FCI with Storage Spaces Direct 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 have in place before you start.

要了解的事项What to know

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

要注意一点是,在 Azure IaaS VM 来宾故障转移群集上,我们建议每个服务器(群集节点)使用一个 NIC 和一个子网。One thing to be aware of 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. 群集验证报告将发出警告,指出节点只能在单个网络上访问。The cluster validation report will warn you that the nodes are reachable only on a single network. 在 Azure IaaS VM 来宾故障转移群集上,可以忽略此警告。You can ignore this warning on Azure IaaS VM guest failover clusters.

此外,应该对以下技术有大致的了解:You should also have a general understanding of these 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 you complete the steps in this article, you should already have:

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

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

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

  1. 使用订阅登录到 Azure 门户Sign 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. 它确保应用程序不会受到单一故障点(例如网络交换机或服务器机架电源装置)的影响。It ensures your application isn't affected by single points of failure, like the network switch or the power unit of a rack of servers.

    如果尚未为虚拟机创建资源组,请在创建 Azure 可用性集时执行该操作。If you haven't 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, take these steps:

    1. 在 Azure 门户中,选择“创建资源”打开 Azure 市场。In the Azure portal, select Create a resource to open the Azure Marketplace. 搜索“可用性集”。Search for Availability set.
    2. 选择“可用性集”。Select Availability Set.
    3. 选择“创建” 。Select Create.
    4. 在“创建可用性集”下,提供以下值:Under Create availability set, provide these values:
      • 名称:可用性集的名称。Name: A name for the availability set.

      • 订阅:Azure 订阅。Subscription: Your Azure subscription.

      • 资源组:如果想要使用现有的组,请单击“选择现有项”并从列表中选择该组。Resource group: If you want to use an existing group, click Select existing and then select the group from the list. 否则,请选择“新建”并输入组的名称。Otherwise, select Create new and enter a name for the group.

      • 位置:设置要在其中创建虚拟机的位置。Location: Set the location where you plan to create your virtual machines.

      • 容错域:使用默认值 (2)。Fault domains: Use the default (2).

      • 更新域:使用默认值 (5)。Update domains: Use the default (5).

    5. 选择“创建”以创建可用性集。Select 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 as your availability set

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

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

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

      重要

      创建虚拟机后无法设置或更改可用性集。You can't set or change the availability set after you've created a virtual machine.

    从 Azure 市场中选择映像。Choose an image from Azure Marketplace. 可以使用包含 Windows Server 和 SQL Server,或者只包含 Windows Server 的 Azure 市场映像。You can use an Azure Marketplace image that includes Windows Server and SQL Server, or use one that just includes 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, the SQL Server installation software, and the required key.

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

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

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

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

    重要

    创建虚拟机后,请删除预装的独立 SQL Server 实例。After you create the virtual machine, remove the pre-installed standalone SQL Server instance. 设置故障转移群集和存储空间直通之后,使用预装的 SQL Server 媒体创建 SQL Server FCI。You'll use the pre-installed SQL Server media to create the SQL Server FCI after you set up the failover cluster and Storage Spaces Direct.

    或者,可以使用只包含操作系统的 Azure 市场映像。Alternatively, you can use Azure Marketplace images that contain just the operating system. 选择一个 Windows Server 2016 Datacenter 映像,并在设置故障转移群集和存储空间直通后安装 SQL Server FCI。Choose a Windows Server 2016 Datacenter image and install the SQL Server FCI after you set up the failover cluster and Storage Spaces Direct. 此映像不包含 SQL Server 安装媒体。This image doesn't contain SQL Server installation media. 将 SQL Server 安装媒体放在可以针对每个服务器运行该媒体的位置。Place the SQL Server installation media in a location where you can run it for each server.

  4. Azure 在创建虚拟机之后,使用远程桌面协议 (RDP) 连接到每个虚拟机。After Azure creates your virtual machines, connect to each one by using remote desktop protocol (RDP).

    首次使用 RDP 连接到虚拟机时,系统会提示是否允许在网络上发现该电脑。When you first connect to a virtual machine by using RDP, a prompt asks you if you want to allow the PC to be discoverable on the network. 请选择“是”。Select Yes.

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

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

    2. 选择“删除” 。Select Remove.

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

    4. 删除“数据库引擎服务”下的所有功能。Remove all features under Database Engine Services. 不要删除“共享功能”。Don't remove Shared Features. 此时会显示以下屏幕截图中所示的内容:You'll see something like the following screenshot:

      选择功能

    5. 依次选择“下一步”、“删除”。 Select Next, and then select Remove.

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

    在每个虚拟机上的 Windows 防火墙中打开以下端口:On each virtual machine, open these 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 格式化的磁盘,则只能启用不带磁盘合格性检查的存储空间直通。If you attach NTFS-formatted disks, you can enable Storage Spaces Direct only without a 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 you create and configure the virtual machines, you can set up the failover cluster.

步骤 2:使用存储空间直通配置 Windows Server 故障转移群集Step 2: Configure the Windows Server Failover Cluster with Storage Spaces Direct

现在请使用存储空间直通配置故障转移群集。Now you configure the failover cluster with Storage Spaces Direct. 在本部分中,你将完成以下步骤:In this section, you complete these steps:

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

添加 Windows Server 故障转移群集Add Windows Server Failover Clustering

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

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

    若要通过 UI 安装故障转移群集,请在两个虚拟机上执行以下步骤:To install Failover Clustering from the UI, take these steps on both virtual machines:

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

    若要使用 PowerShell 安装故障转移群集,请在某个虚拟机上通过管理员 PowerShell 会话运行以下脚本:To install Failover Clustering by using 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 further reference about the next steps, see the instructions under Step 3 of Hyper-converged solution using Storage Spaces Direct in Windows Server 2016.

验证群集Validate the cluster

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

若要使用 UI 验证群集,请在某个虚拟机中执行以下步骤:To validate the cluster by using the UI, take the following steps on one of the virtual machines:

  1. 在“服务器管理器”下,依次选择“工具”、“故障转移群集管理器”。 Under Server Manager, select Tools, and then select Failover Cluster Manager.

  2. 在“故障转移群集管理器”下,依次选择“操作”、“验证配置”。 Under Failover Cluster Manager, select Action, and then select Validate Configuration.

  3. 选择“下一步”。Select Next.

  4. 在“选择服务器或群集”下,输入两个虚拟机的名称。Under Select Servers or a Cluster, enter the names of both virtual machines.

  5. 在“测试选项”下,选择“仅运行选择的测试”。 Under Testing options, select Run only tests I select. 选择“下一步”。Select Next.

  6. 在“测试选择”下,选择除“存储”以外的所有测试,如下所示: Under Test Selection, select all tests except for Storage, as shown here:

    选择群集验证测试

  7. 选择“下一步”。Select Next.

  8. 在“确认”下,选择“下一步”。 Under Confirmation, select Next.

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

若要使用 PowerShell 验证群集,请在某个虚拟机上通过管理员 PowerShell 会话运行以下脚本:To validate the cluster by using 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

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

  • 要成为群集节点的虚拟机的名称The names of the virtual machines that will 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's not used on the same Azure virtual network and subnet as the cluster nodes.

Windows Server 2008 至 Windows Server 2016Windows Server 2008 through Windows Server 2016

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

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

Windows Server 2019Windows Server 2019

以下 PowerShell 脚本为 Windows Server 2019 创建故障转移群集。The following PowerShell script creates a failover cluster for Windows Server 2019. 有关详细信息,请参阅故障转移群集:群集网络对象For more information, see Failover cluster: Cluster Network Object. 使用节点的名称(虚拟机名称)以及 Azure 虚拟网络中可用的 IP 地址更新脚本。Update the script with the names of the nodes (the virtual machine names) and an available IP address from the Azure virtual network.

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

创建云见证Create a cloud witness

云见证是 Azure 存储 Blob 中存储的新型群集仲裁见证。Cloud Witness is a new type of cluster quorum witness that's stored in an Azure storage blob. 使用云见证就无需单独使用一个 VM 来托管见证共享。This removes the need for a separate VM that hosts 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.

添加存储Add storage

存储空间直通的磁盘需是空的。The disks for Storage Spaces Direct need to be empty. 它们不能包含分区或其他数据。They can't contain partitions or other data. 若要清理磁盘,请遵循此指南中的步骤To clean the disks, follow the steps in this guide.

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

    以下 PowerShell 脚本启用存储空间直通:The following PowerShell script enables Storage Spaces Direct:

    Enable-ClusterS2D
    

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

  2. 创建卷Create a volume.

    启用存储空间直通后,它会自动创建存储池。Storage Spaces Direct automatically creates a storage pool when you enable it. 接下来,可以创建卷。You're now ready to create a volume. PowerShell cmdlet New-Volume 自动完成卷的创建过程。The PowerShell cmdlet New-Volume automates the volume creation process. 此过程包括格式化卷、将卷添加到群集,以及创建群集共享卷 (CSV)。This process includes formatting, adding the volume to the cluster, and creating a Cluster Shared Volume (CSV). 此示例创建一个 800 千兆字节 (GB) 的 CSV:This 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\.

    此屏幕截图显示启用了存储空间直通的群集共享卷:This screenshot shows a Cluster Shared Volume with Storage Spaces Direct:

    群集共享卷

步骤 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 by using Failover Cluster Manager and move the storage from one node to the other, you're ready to configure the FCI.

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

配置故障转移群集和所有群集组件(包括存储)后,可以创建 SQL Server FCI。After you've 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 by using RDP.

  2. 在“故障转移群集管理器”中,确保所有核心群集资源位于第一个虚拟机上。In Failover Cluster Manager, make sure all Core Cluster Resources are on the first virtual machine. 如有必要,请将所有资源移到该虚拟机。If necessary, move all resources to that 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. 选择“设置”。Select Setup.

  4. 在“SQL Server 安装中心”中选择“安装”。 In SQL Server Installation Center, select Installation.

  5. 选择“新建 SQL Server 故障转移群集安装”。Select 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. 使用存储空间直通时,该存储不是共享磁盘,而是每个服务器上的卷的装入点。With Storage Spaces Direct, it's not a shared disk, but a mount point to a volume on each server. 存储空间直通在两个节点之间同步该卷。Storage Spaces Direct 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.

    数据目录

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

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

  8. 打开“SQL Server 安装中心”。Open the SQL Server Installation Center. 选择“安装”。Select Installation.

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

    备注

    如果使用了包含 SQL Server 的 Azure 市场库映像,该映像已随附 SQL Server 工具。If you used an Azure Marketplace gallery image that contains SQL Server, SQL Server tools were included with the image. 如果未使用其中的某个映像,请单独安装 SQL Server 工具。If you didn't use one of those images, 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 the 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 负载均衡器For more information, see 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 that contains the virtual machines.

  2. 选择“添加” 。Select Add. 在 Azure 市场中搜索“负载均衡器”。Search the Azure Marketplace for Load Balancer. 选择“负载均衡器”。Select Load Balancer.

  3. 选择“创建” 。Select Create.

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

    • 订阅:Azure 订阅。Subscription: Your Azure subscription.
    • 资源组:包含你的虚拟机的资源组。Resource group: The resource group that contains your virtual machines.
    • 名称:标识负载均衡器的名称。Name: A name that identifies the load balancer.
    • 区域:包含你的虚拟机的 Azure 位置。Region: The Azure location that contains your virtual machines.
    • 类型:公共或专用。Type: Either public or private. 可从虚拟网络内部访问专用负载均衡器。A private load balancer can be accessed from within the virtual network. 大多数 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.
    • SKU:标准。SKU: Standard.
    • 虚拟网络:虚拟机所在的网络。Virtual network: The same network as the virtual machines.
    • IP 地址分配:静态。IP address assignment: Static.
    • 专用 IP 地址:分配给 SQL Server FCI 群集网络资源的 IP 地址。Private IP address: The IP address that you assigned to the SQL Server FCI cluster network resource.

    以下屏幕截图显示了“创建负载均衡器”UI:The following screenshot shows the Create load balancer UI:

    设置负载均衡器

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

  1. 返回到包含虚拟机的 Azure 资源组,找到新的负载均衡器。Return to the Azure resource group that contains the virtual machines and locate the new load balancer. 可能需要在资源组中刷新视图。You might need to refresh the view on the resource group. 选择负载均衡器。Select the load balancer.

  2. 依次选择“后端池”、“添加”。 Select Backend pools, and then select Add.

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

  4. 在“目标网络 IP 配置”下选择“虚拟机”,并选择要作为群集节点参与操作的虚拟机。 Under Target network IP configurations, select 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. 选择“确定”以创建后端池。Select OK to create the backend pool.

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

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

  2. 选择“添加” 。Select Add.

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

    • 名称:运行状况探测的名称Name: A name for the health probe
    • 协议:TCPProtocol: 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. 选择“确定” 。Select OK.

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

  1. 在负载均衡器边栏选项卡上,选择“负载均衡规则”。On the load balancer blade, select Load balancing rules.

  2. 选择“添加” 。Select Add.

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

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

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

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

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

以下列表描述了需要更新的值:The following list describes the values that you need to update:

  • <Cluster Network Name>:Windows Server 故障转移群集的网络名称。<Cluster Network Name>: The Windows Server Failover Cluster name for the network. 在“故障转移群集管理器” > “网络”中,右键单击该网络并选择“属性”。 In Failover Cluster Manager > Networks, right-click the network and select 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>: The 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 select 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>: 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 the cluster parameters in PowerShell. 运行此脚本:Run this script:

Get-ClusterResource $IPResourceName | Get-ClusterParameter 

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

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

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

  2. 打开“故障转移群集管理器”。Open Failover Cluster Manager. 选择“角色”。Select 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. 依次选择“移动”、“可能最佳的节点”。 Select Move, and then select 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, sign 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 you need to, 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 isn't supported on Windows Server 2016 or earlier because:

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

另请参阅See also

使用远程桌面设置存储空间直通 (Azure)Set up Storage Spaces Direct with remote desktop (Azure)

使用存储空间直通的超融合解决方案Hyper-converged solution with Storage Spaces Direct

存储空间直通概述Storage Spaces Direct Overview

SQL Server 对存储空间直通的支持SQL Server support for Storage Spaces Direct