使用存储空间直通创建 FCI(Azure VM 上的 SQL Server)Create an FCI with Storage Spaces Direct (SQL Server on Azure VMs)

适用于: Azure VM 上的 SQL Server

本文介绍了如何使用存储空间直通为 Azure 虚拟机 (VM) 上的 SQL Server 创建故障转移群集实例 (FCI)。This article explains how to create a failover cluster instance (FCI) by using Storage Spaces Direct with SQL Server on Azure Virtual Machines (VMs). 存储空间直通充当基于软件的虚拟存储区域网络 (VSAN),在 Windows 群集中的节点 (Azure VM) 之间同步存储(数据磁盘)。Storage Spaces Direct acts as a software-based virtual storage area network (VSAN) that synchronizes the storage (data disks) between the nodes (Azure VMs) in a Windows cluster.

若要了解详细信息,请参阅对 Azure VM 上的 SQL Server 的 FCI群集最佳做法的概述。To learn more, see an overview of FCI with SQL Server on Azure VMs and cluster best practices.

概述Overview

存储空间直通 (S2D) 支持两种类型的体系结构:融合与超融合。Storage Spaces Direct (S2D) supports two types of architectures: converged and hyperconverged. 超融合基础设施将存储放置在托管群集应用程序的服务器上,使存储位于每个 SQL Server FCI 节点上。A hyperconverged infrastructure places the storage on the same servers that host the clustered application, so that storage is on each SQL Server FCI node.

下图显示了完整的解决方案,该解决方案将超融合存储空间直通与 Azure VM 上的 SQL Server 配合使用:The following diagram shows the complete solution, which uses hyperconverged Storage Spaces Direct with SQL Server on Azure VMs:

使用超融合存储空间直通的完整解决方案的示意图

上图显示了同一资源组中的以下资源:The preceding diagram shows the following resources in the same resource group:

  • 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 中基于模板创建整个解决方案。You can create this entire solution in Azure from a template. GitHub Azure 快速入门模板页面上提供了一个模板示例。An example of a template is available on the GitHub Azure quickstart templates page. 此示例不是针对任何特定工作负荷设计的,也没有针对任何特定工作负荷进行测试。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.

先决条件Prerequisites

在按本文中的说明操作之前,你应已具备以下条件:Before you complete the instructions in this article, you should already have:

  • Azure 订阅。An Azure subscription. 可以从试用版开始。Get started for trial.
  • 可用性集中两个或更多个已准备好的 Windows Azure 虚拟机。Two or more prepared Windows Azure virtual machines in an availability set.
  • 有权限在 Azure 虚拟机和 Active Directory 中创建对象的帐户。An account that has permissions to create objects on both Azure virtual machines and in Active Directory.
  • 最新版本的 PowerShellThe latest version of PowerShell.

添加 Windows 群集功能Add the Windows cluster feature

  1. 使用属于本地管理员且有权在 Active Directory 中创建对象的域帐户,通过远程桌面协议 (RDP) 连接到第一个虚拟机。Connect to the first virtual machine by using Remote Desktop Protocol (RDP) with 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, do the following 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.
    4. 选择“添加功能”。Select Add Features.
    5. 选择“下一步”,然后选择“完成”安装这些功能。 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 more information about the next steps, see the instructions in the "Step 3: Configure Storage Spaces Direct" section of Hyperconverged 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, do the following 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.

  6. 选择“下一页”。Select Next.

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

    选择群集验证测试

  8. 选择“下一页”。Select Next.

  9. 在“确认”下,选择“下一步”。 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 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 2012 到 Windows Server 2016,可通过以下 PowerShell 脚本创建故障转移群集。The following PowerShell script creates a failover cluster for Windows Server 2012 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

配置仲裁Configure quorum

配置最符合业务需求的仲裁解决方案。Configure the quorum solution that best suits your business needs. 你可以配置磁盘见证云见证文件共享见证You can configure a Disk Witness, a Cloud Witness, or a File Share Witness. 有关详细信息,请参阅 SQL Server VM 上的仲裁For more information, see Quorum with SQL Server VMs.

添加存储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 instructions in Deploy Storage Spaces Direct.

  1. 启用存储空间直通Enable Storage 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 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 you've run the preceding command, an 800-GB volume is mounted as a cluster resource. 该卷位于 C:\ClusterStorage\Volume1\The volume is at C:\ClusterStorage\Volume1\.

    此屏幕截图显示了一个采用存储空间直通的 CSV:This screenshot shows a CSV with Storage Spaces Direct:

    屏幕截图显示采用存储空间直通的群集共享卷

测试群集故障转移Test cluster failover

测试你的群集的故障转移。Test the failover of your cluster. 在“故障转移群集管理器”中,右键单击你的群集并选择“更多操作” > “移动核心群集资源” > “选择节点”,然后选择群集的其他节点。 In Failover Cluster Manager, right-click your cluster, select More Actions > Move Core Cluster Resource > Select node, and then select the other node of the cluster. 将核心群集资源移到群集的每个节点,再将它移回主节点。Move the core cluster resource to every node of the cluster, and then move it back to the primary node. 如果可以成功将群集移到每个节点,则表示你已为安装 SQL Server 做好了准备。If you can successfully move the cluster to each node, you're ready to install SQL Server.

通过将核心资源移到其他节点来测试群集故障转移

创建 SQL Server FCICreate 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. 该卷作为 CSV 提供给群集。The volume is presented to the cluster as a CSV. 使用数据目录的 CSV 装入点。Use the CSV mount point for the data directories.

    数据目录

  6. 根据向导中的说明完成操作后,安装程序会在第一个节点上安装 SQL Server FCI。After you complete the instructions in the wizard, Setup installs 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. 有关详细信息,请参阅 下载 SQL Server Management Studio (SSMS)For more information, see Download SQL Server Management Studio (SSMS).

安装 SQL IaaS 代理Install the SQL IaaS Agent

若要获取门户集成和 SQL VM 功能,必须安装 SQL Server IaaS 代理扩展To get portal integration and SQL VM features, you must install the SQL Server IaaS Agent Extension. 若要在新 VM 上安装该代理,请在创建 VM 后运行以下命令。To install the agent on the new VM, run the following command after the VM is created.

Set-AzVMSqlServerExtension -ResourceGroupName $ResourceGroupName -VMName $VMName -name "SQLIaasExtension" -version "2.0" -Location $Location

配置连接Configure connectivity

若要将流量正确路由到当前主节点,请配置适用于你的环境的连接选项。To route traffic appropriately to the current primary node, configure the connectivity option that's suitable for your environment. 你可以创建 Azure 负载均衡器,也可以在使用 SQL Server 2019 CU2(或更高版本)和 Windows Server 2016(或更高版本)的情况下改用分布式网络名称功能。You can create an Azure load balancer or, if you're using SQL Server 2019 CU2 (or later) and Windows Server 2016 (or later), you can use the distributed network name feature instead.

限制Limitations

  • Azure 虚拟机支持 Windows Server 2019 上的 Microsoft 分布式事务处理协调器 (MSDTC),其中的存储位于 CSV 和标准负载均衡器上。Azure virtual machines support Microsoft Distributed Transaction Coordinator (MSDTC) on Windows Server 2019 with storage on CSVs and a standard load balancer.
  • 如果将存储添加到群集,则仅当未选中或清除了磁盘资格选项时,已作为 NTFS 格式的磁盘附加的磁盘才能与存储空间直通一起使用。Disks that have been attached as NTFS-formatted disks can be used with Storage Spaces Direct only if the disk eligibility option is unchecked, or cleared, when storage is being added to the cluster.

后续步骤Next steps

使用虚拟网络名称和 Azure 负载均衡器分布式网络名称 (DNN) 配置到 FCI 的连接(如果尚未执行此操作)。If you haven't already done so, configure connectivity to your FCI with a virtual network name and an Azure load balancer or distributed network name (DNN).

如果存储空间直通不是适合你的 FCI 存储解决方案,请考虑改用 Azure 共享磁盘高级文件共享来创建 FCI。If Storage Spaces Direct isn't the appropriate FCI storage solution for you, consider creating your FCI by using Azure shared disks or Premium File Shares instead.

若要了解详细信息,请参阅对 Azure VM 上的 SQL Server 的 FCI群集配置最佳做法的概述。To learn more, see an overview of FCI with SQL Server on Azure VMs and cluster configuration best practices.

有关详细信息,请参阅:For more information, see: