

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 FSx 适用于 Windows 文件服务器在亚马逊 EC2 上设置微软 SQL Server 故障转移群集
<a name="microsoft-sql-failover-cluster-on-amazon-ec2"></a>

*Sweta Krishna 和 Ramesh Babu Donti，Amazon Web Services*

## Summary
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-summary"></a>

带失效转移集群实例（FCI）的 Microsoft SQL Server Standard 版可以成为 SQL Server Enterprise 的更具成本效益的替代方案。设置 SQL FCI 需要在节点之间共享文件存储，而 [Amazon FSx for Windows File Server](https://aws.amazon.com/fsx/windows/) 提供了完全托管的存储，可在可用区之间自动同步复制。Amazon 通过为通用文件共享使用内置的重复数据删除功能来 FSx 降低存储成本，从而无需维护第三方解决方案。Amazon FSx 还支持以下内容：
+ 只需要按实际使用情况付费，没有最低费用，也无需预付费。
+ 使用 Amazon FSx 作为您的共享存储空间，手动设置 FCI。
+ 使用 Amazon FSx 作为 SQL 集群的文件共享见证人。
+ Amazon FSx for Windows File Server 支持服务器消息块 (SMB) 3.0 以实现持续可用的文件共享，因此适合 SQL Server FCI 部署。

## 先决条件和限制
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-prereqs"></a>

**先决条件**
+ 活跃[AWS 账户](https://aws.amazon.com/account/)。
+ 创建和管理亚马逊虚拟私有云 (Amazon VPC) 资源、亚马逊弹性计算云 (Amazon EC2) 实例、安全组 AWS Identity and Access Management 和 (IAM) 角色的权限。
+ AWS Managed Microsoft AD 或者你自己的本地活动目录。
+ 具有设置失效转移集群[所需权限](https://learn.microsoft.com/en-us/windows-server/failover-clustering/configure-failover-cluster-accounts)的 Active Directory 域用户。
+ 针对 SQL Server FCI 和 [Microsoft Active Directory 端口](https://docs.aws.amazon.com/whitepapers/latest/access-workspaces-with-access-cards/ip-address-and-port-requirements.html)的安全组规则，旨在实现安全的混合连接。
+ 在 Active Directory 中为 SQL Server 配置了具有跨 SQL 节点适当权限的[服务账户](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions?view=sql-server-ver16#sql-server-failover-cluster-instance)。
+ Amazon FSx for Windows 文件服务器位于故障转移群集中。
+ SQL Server 安装二进制文件。

**限制**
+ 有些 AWS 服务 并非全部可用 AWS 区域。有关区域可用性，请参阅[按区域划分的AWS 服务](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。有关特定端点，请参阅[服务端点和配额](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)页面，然后选择相应服务的链接。

**产品版本**
+ Amazon EC2 for Windows Server 2012 R2 或更高版本
+  FSx 适用于Windows的亚马逊文件服务器，所有当前的Windows服务器版本
+  FSx 适用于 NetApp ONTAP 的 Amazon 作为共享存储的替代方案
+ SQL Server 2012/2016/2019/2022

## 架构
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-architecture"></a>

**技术堆栈**
+ Amazon EC2
+  FSx 适用于 Windows 文件服务器的亚马逊
+ Amazon VPC
+ AWS Directory Service
+ AWS Systems Manager
+ IAM

**目标架构**

下图显示了在亚马逊 EC2 上使用亚马逊 Windows 文件服务器的 Microsoft SQL Server FCI FSx 的高级架构。

![在亚马逊 EC2 上使用亚马 FSx 逊 Windows 文件服务器的 Microsoft Server FCI 架构图。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/208bf64a-8fef-4019-944a-723372450885/images/ba0c9169-9536-41c3-ae8e-7264dcc3e1ad.png)


**网络基础架构**
+ Amazon VPC 提供了跨三个可用区的网络容器。
+ 私有子网在每个可用区中提供隔离的子网，用于部署资源。

**计算层**
+ Amazon EC2 包含 SQL Server 集群节点 1，作为 Windows Server 失效转移集群（WSFC）的一部分，部署在可用区 1 中。
+ Amazon EC2 包含 SQL Server 集群节点 2，作为 WSFC 的一部分，部署在可用区 2 中。
+ WSFC 集群连接两个 SQL Server 节点以实现失效转移功能。

**适用于 Windows 文件服务器 FSx 的亚马逊存储层**

**多可用区 FSx 部署（跨可用区 1 和 2）**
+ 可用区 1 中的主 FSx 文件系统托管活动的 SQL Server 数据和日志文件。
+ 可用区 2 中的辅助 FSx 文件系统提供自动故障转移功能。
+ 共享的 SMB 文件共享（\\\\fsx.domain\\sqlshare），SQL Server 数据库的两个集群节点都可以访问。

**单可用区 FSx 部署（中 AZ3）**
+ 可用区 3 中的 Amazon FSx 文件服务器见证人充当集群法定人数见证人。
+ 文件共享见证（`\\fsx.domain\witness`）维护集群仲裁并防止出现脑裂的情况。

**目录服务**
+ AWS Managed Microsoft AD 提供群集功能所需的 Windows 身份验证和域服务。

**高可用性功能**
+ 多可用区组件提供跨可用区的容错能力。
+ FSx 如果主服务器出现故障，备用文件服务器可自动进行故障转移。
+ 文件共享见证在可用区 3 中提供集群仲裁管理，以帮助确保集群在发生故障期间正常运行。
+ 与域集成，可实现无缝 AWS Managed Microsoft AD 的 Windows 身份验证。

## 工具
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-tools"></a>

**AWS 服务**
+ [Amazon Elastic Compute Cloud（Amazon EC2）](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)在 AWS Cloud中提供可扩展的计算容量。您可以根据需要启动任意数量的虚拟服务器，并快速纵向扩展或缩减这些服务器。
+ [Amazon FSx](https://docs.aws.amazon.com/fsx/?id=docs_gateway) 提供的文件系统支持行业标准的连接协议，并提供高可用性和跨 AWS 区域复制功能。
+ [Amazon Virtual Private Cloud（亚马逊 VPC）](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html)可帮助您将 AWS 资源启动到您定义的虚拟网络中。该虚拟网络类似于您在数据中心中运行的传统网络，并具有使用 AWS的可扩展基础设施的优势。
+ [AWS Directory Service for Microsoft Active Directory](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_microsoft_ad.html)允许你的目录感知工作负载和 AWS 资源使用中的 Microsoft Active Directory。 AWS Cloud
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 通过控制谁经过身份验证并有权使用 AWS 资源，从而帮助您安全地管理对资源的访问权限。
+ [AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html) 可帮助您管理在 AWS Cloud中运行的应用程序和基础设施。它简化了应用程序和资源管理，缩短了检测和解决操作问题的时间，并帮助您大规模安全地管理 AWS 资源。

## 最佳实践
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-best-practices"></a>
+ 将数据库实例放在私有子网中，以保护它们不被从 Internet 公开访问，同时仍允许它们连接到 AWS 服务 并执行更新。
+  PowerShell 要使用管理您的 Amazon FSx for Windows 文件服务器，[ FSx 请参阅管理 Windows 文件系统](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/administering-file-systems.html)。

## 操作说明
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-epics"></a>

### 为 SQL Server 创建和配置 Amazon EC2 节点
<a name="create-and-configure-ec2-nodes-for-sql-server"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 添加名称和标签。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 选择 Windows AMI。 | 选择适用于 Windows 且符合您的 SQL Server 要求的亚马逊机器映像（AMI）。 | 数据库管理员 | 
| 选择一个实例类型。 | 选择符合您要求的 Amazon EC2 实例类型。 | 数据库管理员 | 
| 使用密钥对。 | 您可以使用密钥对安全地连接到实例。在启动实例之前，请确保您可以访问所选的密钥对。 | 数据库管理员 | 
| 配置网络设置。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 配置高级网络设置。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 配置存储。 | 配置所需的总存储空间并选择所需的存储类型。 | 数据库管理员 | 
| 配置高级详细信息并启动实例。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 创建节点 2。 | 重复这些步骤以创建和配置节点 2。 | 数据库管理员 | 

### 在节点 1 及 2 上安装和配置 Windows Server 失效转移集群
<a name="install-and-configure-windows-server-failover-cluster-on-nodes-1-and-2"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 登录到节点 1。 | 以管理员身份登录 Windows Amazon EC2 实例。 | 数据库管理员 | 
| 在节点 1 上安装 FCI 功能。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html)<pre>Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools</pre>[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 登录到节点 2。 | 以管理员身份登录 Windows Amazon EC2 实例。 | 数据库管理员 | 
| 在节点 2 上安装 FCI 功能。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html)<pre>Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools</pre>[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 向集群添加节点。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 让集群上线。 | 要让集群上线，请更新两个节点的静态 IP 地址：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 验证集群。 | 导航到**失效转移集群管理器**并验证集群核心资源是否处于在线状态。 | 数据库管理员 | 

### 在节点 1 和 2 上安装 SQL Server
<a name="install-sql-server-on-nodes-1-and-2"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 登录至服务器。 | 以管理员身份登录 Amazon EC2 实例。 | 数据库管理员 | 
| 装载 SQL 二进制文件。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) |  | 
| 将节点 2 添加到失效转移集群。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 

### 配置 Amazon FSx 文件共享见证
<a name="configure-the-fsx-file-share-witness"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 配置仲裁设置。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/microsoft-sql-failover-cluster-on-amazon-ec2.html) | 数据库管理员 | 
| 检索 DNS 详细信息。 | 在 Amazon FSx 控制台中，选择**托管 AD**，然后选择 “**附加**”。DNS 应采用以下格式：`\\example.example.net\share` | 数据库管理员 | 
| 配置文件共享见证。 | 选择 **Amazon FSx 文件共享路径**，然后选择 “**完成**”。 | 数据库管理员 | 

## 相关的资源
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-resources"></a>

**AWS resources**
+ [亚马逊 Window FSx s 文件服务器](https://www.youtube.com/watch?v=IMDWTIShlyI)（视频）
+ [深入了解亚马逊 Window FSx s 文件服务器版](https://www.youtube.com/watch?v=_x_Geur93oc)（视频）
+ [如何在 Windows 服务器上部署带亚马逊 EBS 多重连接的 SQL Server 故障转移群集](https://aws.amazon.com/blogs/modernizing-with-aws/how-to-deploy-a-sql-server-failover-cluster-with-amazon-ebs-multi-attach-on-windows-server/)（AWS 博客文章）
+ [使用 FSx 适用于 Windows 的亚马逊文件服务器简化微软 SQL Server 高可用性部署](https://aws.amazon.com/blogs/storage/simplify-your-microsoft-sql-server-high-availability-deployments-using-amazon-fsx-for-windows-file-server/)（AWS 博客文章）
+ [使用亚马逊 FSx 适用于 NetApp ONTAP 的 SQL Server 高可用性部署](https://aws.amazon.com/blogs/modernizing-with-aws/sql-server-high-availability-amazon-fsx-for-netapp-ontap/)（AWS 博客文章）
+ [ FSx 用于搭载微软 SQL Server 的 Windows 文件服务器](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/sql-server.html)
+ [什么 FSx 适用于 Windows 文件服务器？](https://docs.aws.amazon.com/fsx/latest/WindowsGuide/what-is.html)

**其他资源**
+ [创建失效转移集群](https://learn.microsoft.com/en-us/windows-server/failover-clustering/create-failover-cluster?pivots=windows-admin-center)

## 附加信息
<a name="microsoft-sql-failover-cluster-on-amazon-ec2-additional"></a>

**配置文件共享见证**

通过在 Amazon FSx 安全组中添加允许入站连接的规则，确保您已从两个节点连接到文件系统。应允许 SMB 端口。在本示例中，如果 DNS 名称为 `\\example.example.com\share`，则使用 `\\example.example.com\share`。在 Always On 可用性集群中对文件共享见证使用相同的值。按照以下步骤配置文件共享见证：

1. 使用 RDP 连接到您的 Amazon EC2 实例。

1. 导航到**失效转移集群管理器**。

1. 打开上下文（右键单击）菜单，然后选择**更多操作**。

1. 选择**配置集群仲裁设置**。

1. 选择**下一步**。

1. 选择**仲裁配置**并配置文件共享见证。

1. 提供 DNS 名称。

1. 查看摘要，然后选择**完成**。文件共享见证应在**集群核心**资源部分显示为联机状态。