

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

# 使用为适用于微软 SQL Server 的亚马逊 RDS 配置 Windows 身份验证 AWS Managed Microsoft AD
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad"></a>

*Ramesh Babu Donti，Amazon Web Services*

## Summary
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-summary"></a>

此模式显示如何使用 AWS Directory Service for Microsoft Active Directory () 为 SQL Server 实例的亚马逊关系数据库服务 (Amazon RDS AWS Managed Microsoft AD) 配置 Windows 身份验证。Windows 身份验证允许用户使用其域凭证而不是数据库特定的用户名和密码连接到 RDS 实例。

您可以在创建新的 RDS SQL Server 数据库时启用 Windows 身份验证，也可以通过将其添加到现有数据库实例来启用 Windows 身份验证。数据库实例与集成 AWS Managed Microsoft AD ，为访问 SQL Server 数据库的域用户提供集中身份验证和授权。

此配置利用现有的 Active Directory 基础设施来增强安全性，并且无需为域用户管理单独的数据库凭证。

## 先决条件和限制
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-prereqs"></a>

**先决条件**
+  AWS 账户 具有适当权限的活跃用户
+ 具有以下特性的虚拟私有云（VPC）：
  + 已配置的互联网网关和路由表
  + 公有子网中的 NAT 网关（如果实例需要访问互联网）
+ AWS Identity and Access Management (IAM) 角色：
  + 具有以下 AWS 托管策略的域角色：
    + `AmazonSSMManagedInstanceCore`启用 AWS Systems Manager
    + `AmazonSSMDirectoryServiceAccess`，可提供将实例加入目录的权限
  + RDS 增强监控角色（如果启用了增强监控）
+ 安全组：
  + 允许使用 Active Directory 通信端口的目录服务安全组
  + 允许 RDP `3389` 和域名通信的亚马逊弹性计算云 (Amazon EC2) 安全组
  + RDS 安全组，允许来自授权来源的 SQL Server 端口 `1433`
+ 网络连接：
  + 正确的 DNS 解析以及子网之间的网络连接

**限制**
+ 有关 RDS AWS 区域 for SQL Server 的支持 AWS Managed Microsoft AD 的信息，请参阅[区域和版本可用性](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_SQLServerWinAuth.html#USER_SQLServerWinAuth.RegionVersionAvailability)。
+ 有些 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)页面，然后选择相应服务的链接。

## 架构
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-architecture"></a>

**源技术堆栈**
+ 本地活动目录或 AWS Managed Microsoft AD

**目标技术堆栈**
+ Amazon EC2
+ Amazon RDS for Microsoft SQL Server
+ AWS Managed Microsoft AD

**目标架构**

![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/e02f6059-6631-46f6-819c-5961af7ba4ae/images/1aa50e3b-b4f6-4d44-9f9e-6cbb248a159c.png)


该架构包括以下内容：
+ 将 Amazon EC2 实例加入 AWS Managed Microsoft AD 域名的 IAM 角色。
+ 用于数据库管理和测试的亚马逊 EC2 Windows 实例。
+ Amazon VPC，其私有子网用于托管 Amazon RDS 实例和跨可用区的内部资源。
+ 网络访问控制安全组：
  + Amazon RDS 安全组，用于控制来自授权来源的 SQL Server 端口 `1433` 的入站访问。
  + 一个 Amazon EC2 安全组，用于通过端口`3389`和域通信端口管理 RDP 访问。
  + Active Directory 的目录服务安全组，可通过端口 `53`、`88`、`389` 和 `445` 进行通讯。
+ AWS Managed Microsoft AD 为 Windows 资源提供集中式身份验证和授权服务。
+ 私有子网中的 Amazon RDS for SQL Server 数据库实例，并且已启用 Windows 身份验证。

## 工具
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-tools"></a>

**AWS 服务**
+ [亚马逊弹性计算云 (Amazon EC2)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html) 在中提供可扩展的计算容量 AWS 云。您可以根据需要启动任意数量的虚拟服务器，并快速纵向扩展或缩减这些服务器。
+ Amazon Relational Database Service（Amazon RDS）可帮助您在 AWS 云中设置、操作和扩展关系数据库。
+ [AWS Directory Service](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/what_is.html)提供了多种使用微软 Active Directory (AD) 的方法， AWS 服务 例如亚马逊弹性计算云 (亚马逊 EC2)、适用于 SQL Server 的亚马逊关系数据库服务 (Amazon RDS) 和 FSx 适用于 Windows 文件服务器的亚马逊。
+ [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 云
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html) 通过控制谁经过身份验证并有权使用 AWS 资源，从而帮助您安全地管理对资源的访问权限。

**其他服务**
+ [Microsoft SQL Server Management Studio (SSMS)](https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms) 是一款用于管理 SQL Server 的工具，包括访问、配置和管理 SQL Server 组件。

## 最佳实践
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-best-practices"></a>
+ 有关一般最佳实践，请参阅 [Amazon RDS 的最佳实践](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_BestPractices.html)。

## 操作说明
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-epics"></a>

### 配置 AWS Managed Microsoft AD
<a name="configure-managed-ad"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 设置目录类型。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置目录信息。 | 在**目录信息**部分中，输入所需信息，并保留可选值：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置 VPC 和子网。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 审视和创建目录。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 

### 创建和配置 Amazon EC2 实例
<a name="create-and-configure-an-ec2-instance"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 为 Windows 配置 AMI。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置网络设置。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置存储。 | 根据需要配置 Amazon EBS 卷。 | 数据库管理员、工程师 DevOps  | 
| 配置高级详细信息并启动实例。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 

### 使用 Windows 身份验证创建和配置 RDS for SQL Server
<a name="create-and-configure-rds-for-sql-server-with-windows-authentication"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建数据库并配置引擎选项。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| Choose a template。 | 选择符合您要求的示例模板。 | 数据库管理员、工程师 DevOps  | 
| 配置数据库设置。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置实例。 | 在**实例配置**部分的**数据库实例类**下，选择符合您要求的实例大小。 | 数据库管理员、工程师 DevOps  | 
| 配置存储。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置连接。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置 Windows 身份验证。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置监控。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html)注意：若您想了解不同进程或线程对 CPU 的使用差异，指标非常有用。 CloudWatch 如果启用了错误日志，您也可以将**错误日志**导出到 Amazon。 | 数据库管理员、工程师 DevOps  | 
| 配置其他设置。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 查看成本并创建数据库。 | 查看**月度估算费用**部分，然后选择**创建数据库**。 | 数据库管理员、工程师 DevOps  | 

### 配置数据库访问和测试连接
<a name="configure-database-access-and-test-connections"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 连接到 Windows 计算机。 | 连接到您的 Windows 计算机并启动 SQL Server Management Studio。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置 SSMS 连接。 | 使用 Windows 身份验证设置数据库连接。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 配置安全设置。 | 为 SSMS 版本 20 或更高版本设置所需的安全参数。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 
| 创建 Windows 登录。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html)<pre>CREATE LOGIN [<domainName>\<user_name>] FROM WINDOWS;<br />GO</pre> | 数据库管理员、工程师 DevOps  | 
| 测试 Windows 身份验证。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/configure-windows-authentication-for-amazon-rds-using-microsoft-ad.html) | 数据库管理员、工程师 DevOps  | 

## 相关资源
<a name="configure-windows-authentication-for-amazon-rds-using-microsoft-ad-resources"></a>
+ [创建你的 AWS Managed Microsoft AD](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_getting_started_create_directory.html)
+ [将亚马逊 EC2 Windows 实例加入你的 AWS Managed Microsoft AD](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/launching_instance.html)
+ [Amazon RDS 中支持 Kerberos 身份验证的区域和数据库引擎](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RDS_Fea_Regions_DB-eng.Feature.KerberosAuthentication.html)
+ [什么是 SQL Server Management Studio（SSMS）？](https://learn.microsoft.com/en-us/ssms/sql-server-management-studio-ssms)