使用高级文件共享创建 FCI(Azure VM 上的 SQL Server)Create an FCI with a premium file share (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) with SQL Server on Azure Virtual Machines (VMs) by using a premium file share.

高级文件共享以存储空间直通 (SSD) 为基础,可以稳定保持较低的延迟,完全支持用于 Windows Server 2012 或更高版本上的 SQL Server 2012 或更高版本的故障转移群集实例。Premium file shares are Storage Spaces Direct (SSD)-backed, consistently low-latency file shares that are fully supported for use with failover cluster instances for SQL Server 2012 or later on Windows Server 2012 or later. 高级文件共享提供更高的灵活性,使你能在不停机的情况下对文件共享进行大小调整和缩放。Premium file shares give you greater flexibility, allowing you to resize and scale a file share without any downtime.

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

先决条件Prerequisites

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

装载高级文件共享Mount premium file share

  1. 登录 Azure 门户Sign in to the Azure portal. 转到你的存储帐户。and go to your storage account.

  2. 在“文件服务”下转到“文件共享” ,然后选择需要用于 SQL 存储的高级文件共享。Go to File Shares under File service, and then select the premium file share you want to use for your SQL storage.

  3. 选择“连接”使系统显示文件共享的连接字符串。Select Connect to bring up the connection string for your file share.

  4. 在下拉列表中选择要使用的驱动器号,然后将这两个代码块复制到记事本中。In the drop-down list, select the drive letter you want to use, and then copy both code blocks to Notepad.

    从文件共享连接门户复制两个 PowerShell 命令

  5. 使用由 SQL Server FCI 用作服务帐户的帐户通过远程桌面协议 (RDP) 连接到 SQL Server VM。Use Remote Desktop Protocol (RDP) to connect to the SQL Server VM with the account that your SQL Server FCI will use for the service account.

  6. 打开 PowerShell 命令管理控制台。Open an administrative PowerShell command console.

  7. 运行你早些时候在门户中工作时保存的命令。Run the commands that you saved earlier when you were working in the portal.

  8. 使用文件资源管理器或“运行”对话框(选择 Windows键 + R)转到该共享。Go to the share by using either File Explorer or the Run dialog box (select Windows + R). 使用网络路径 \\storageaccountname.file.core.chinacloudapi.cn\filesharenameUse the network path \\storageaccountname.file.core.chinacloudapi.cn\filesharename. 例如: \\sqlvmstorageaccount.file.core.chinacloudapi.cn\sqlpremiumfileshareFor example, \\sqlvmstorageaccount.file.core.chinacloudapi.cn\sqlpremiumfileshare

  9. 在新连接的文件共享上创建至少一个文件夹以将 SQL 数据文件放入其中。Create at least one folder on the newly connected file share to place your SQL data files into.

  10. 在将加入群集的每个 SQL Server VM 上重复这些步骤。Repeat these steps on each SQL Server VM that will participate in the cluster.

重要

  • 考虑对备份文件使用单独的文件共享,以便节省此共享中数据和日志文件占用的每秒输入/输出操作数 (IOPS) 和空间容量。Consider using a separate file share for backup files to save the input/output operations per second (IOPS) and space capacity of this share for data and log files. 可将高级或标准文件共享用于备份文件。You can use either a Premium or Standard File Share for backup files.
  • 如果在 Windows 2012 R2 或更低版本中操作,请遵循相同的步骤来装载要用作文件共享见证的文件共享。If you're on Windows 2012 R2 or earlier, follow these same steps to mount the file share that you're going to use as the file share witness.

添加 Windows 群集功能Add Windows cluster feature

  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, 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}
    

验证群集Validate 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 and Storage Spaces Direct, 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 "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.

测试群集故障转移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, 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 that all the core cluster 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.

  4. 选择“设置”。Select Setup.

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

  6. 选择“新的 SQL Server 故障转移群集安装”,然后按照向导中的说明安装 SQL Server FCI。Select New SQL Server failover cluster installation, and then follow the instructions in the wizard to install the SQL Server FCI.

    FCI 数据目录需位于高级文件共享上。The FCI data directories need to be on the premium file share. 输入共享的完整路径,格式为:\\storageaccountname.file.core.chinacloudapi.cn\filesharename\foldernameEnter the full path of the share, in this format: \\storageaccountname.file.core.chinacloudapi.cn\filesharename\foldername. 系统将显示一条警告,提示你已将文件服务器指定为数据目录。A warning will appear, telling you that you've specified a file server as the data directory. 预计会出现此警告。This warning is expected. 请确保在保存文件共享时通过 RDP 访问 VM 时所用的用户帐户,是 SQL Server 服务用来避免可能的故障的同一帐户。Ensure that the user account you used to access the VM via RDP when you persisted the file share is the same account that the SQL Server service uses to avoid possible failures.

    将文件共享用作 SQL 数据目录

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

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

  9. 打开“SQL Server 安装中心”,然后选择“安装”。 Open the SQL Server Installation Center, and then select Installation.

  10. 选择“将节点添加到 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 with 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).

  11. 在要添加到 SQL Server 故障转移群集实例的任何其他节点上重复这些步骤。Repeat these steps on any other nodes that you want to add to the SQL Server failover cluster instance.

安装 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.

有关群集连接选项的更多详细信息,请参阅将 HADR 连接路由到 Azure VM 上的 SQL ServerFor more details about cluster connectivity options, see Route HADR connections to SQL Server on Azure VMs.

限制Limitations

  • Windows Server 2016 及更低版本不支持 Microsoft 分布式事务处理协调器 (MSDTC)。Microsoft Distributed Transaction Coordinator (MSDTC) is not supported on Windows Server 2016 and earlier.
  • 使用高级文件共享的故障转移群集不支持文件流。Filestream isn't supported for a failover cluster with a premium file share. 若要使用文件流,请改用存储空间直通Azure 共享磁盘部署你的群集。To use filestream, deploy your cluster by using Storage Spaces Direct or Azure shared disks instead.

后续步骤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 premium file shares are not the appropriate FCI storage solution for you, consider creating your FCI by using Azure shared disks or Storage Spaces Direct 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: