

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

# 将 Amazon FSx 与 AWS Directory Service for Microsoft Active Directory 结合使用
<a name="fsx-aws-managed-ad"></a>

AWS Directory Service for Microsoft Active Directory（AWS Managed Microsoft AD）在云中提供完全托管、高度可用的实际 Active Directory 目录。您可以在工作负载部署中使用这些 Active Directory 目录。

如果您的组织使用 AWS Managed Microsoft AD 管理身份和设备，我们建议您将 Amazon FSx 文件系统与 AWS Managed Microsoft AD 集成。此操作将为您提供一个使用 Amazon FSx 和 AWS Managed Microsoft AD 的一站式解决方案。AWS 会处理这两项服务的部署、操作、高可用性、可靠性、安全性和无缝集成，使您能够专注于高效操作自己的工作负载。

您可以使用 Amazon FSx 控制台来将 Amazon FSx 与 AWS Managed Microsoft AD 设置结合使用。在控制台中创建新的 FSx for Windows File Server 文件系统时，请选择 **Windows 身份验证**部分下的 **AWS 托管 Active Directory**。您还可以选择要使用的特定目录。有关更多信息，请参阅 [步骤 5。创建文件系统](getting-started.md#getting-started-step1)。

您的组织可能会在自行管理的 Active Directory 域（本地或云端）上管理身份和设备。如果是，您可以将您的 Amazon FSx 文件系统直接加入到现有的自行管理的 Active Directory 域中。有关更多信息，请参阅 [使用自行管理的 Microsoft Active Directory](self-managed-AD.md)。

此外，您还可以将系统设置为从资源林隔离模型获益。在此模型中，您可以将资源（包括 Amazon FSx 文件系统）隔离到与用户所在的 Active Directory 林相互独立的 AD 林中。

**重要**  
对于单可用区 2 和所有多可用区文件系统，Active Directory 完全限定域名（FQDN）不得超过 47 个字符。

## 联网先决条件
<a name="rfim-networking-requirements"></a>

在创建已加入 AWS Microsoft 托管 Active Directory 域的 FSx for Windows File Server 文件系统之前，请确保您已经创建并设置了以下网络配置：
+ 对于 **VPC 安全组**，用于您的默认 Amazon VPC 的默认安全组已添加到控制台中的文件系统。请确保要在其中创建 FSx 文件系统的子网的安全组和 VPC 网络 ACL 在端口上允许有下图所示方向的流量。  
![\[用于 VPC 安全组的 FSx for Windows File Server 端口配置要求，以及用于要在其中创建文件系统的子网的网络 ACL。\]](http://docs.aws.amazon.com/zh_cn/fsx/latest/WindowsGuide/images/Windows-port-requirements.png)

  下表确定了每个端口的作用。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/fsx/latest/WindowsGuide/fsx-aws-managed-ad.html)
**重要**  
单可用区 2 和所有多可用区文件系统部署都需要允许 TCP 端口 9389 上的出站流量。
**注意**  
如果您使用的是 VPC 网络 ACL，则还必须允许动态端口（49152-65535）上的出站流量。
+ 若要将 Amazon FSx 文件系统连接到位于其他 VPC 或账户中的 AWS 托管 Microsoft Active Directory，则请确保此 VPC 与您要在其中创建文件系统的 Amazon VPC 之间已建立连接。有关更多信息，请参阅 [在不同的 VPC 或账户中将 Amazon FSx 与 AWS Managed Microsoft AD 结合使用](shared-mad.md)。
**重要**  
虽然 Amazon VPC 安全组要求仅在发起网络流量的方向打开端口，但大多数 VPC 网络 ACL 要求双向打开端口。

使用 [Amazon FSx 网络验证工具](validate-ad-domain-controllers.md#test-ad-controller-connectivity)验证与 Active Directory 域控制器之间的连接。

## 使用资源林隔离模型
<a name="using-a-rfim"></a>

将文件系统加入到 AWS Managed Microsoft AD 设置。即可在您创建的 AWS Managed Microsoft AD 域和现有的自行管理的 Active Directory 域之间建立单向林信任关系。对于 Amazon FSx 中的 Windows 身份验证，您只需要单向林信任，即 AWS 托管的林信任企业域林。

您的企业域为受信任域，而 Directory Service 托管的域为信任域。经过验证的身份验证请求只能在域之间单向传输，即允许企业域中的账户根据托管的域中共享的资源进行身份验证。在这种情况下，Amazon FSx 仅与 AWS 托管的域进行交互。在 Kerberos 身份验证场景中，来自公司客户端的身份验证请求由公司域进行验证，然后公司域将其转交给 AWS Managed Microsoft AD，最后客户端向 FSx for Windows File Server 文件系统提交服务票证。有关信任的更多信息，请参阅 AWS 安全博客中的 [Everything you wanted to know about trusts with AWS Managed Microsoft AD](https://aws.amazon.com/blogs/security/everything-you-wanted-to-know-about-trusts-with-aws-managed-microsoft-ad/)。

## 测试 Active Directory 配置
<a name="test-ad-config"></a>

在创建 Amazon FSx 文件系统之前，我们建议您使用 Amazon FSx 网络验证工具验证与 Active Directory 域控制器之间的连接。有关更多信息，请参阅 [验证与 Active Directory 域控制器的连接](validate-ad-domain-controllers.md)。

下列相关资源能够帮助您将 AWS Directory Service for Microsoft Active Directory 与 FSx for Windows File Server 结合使用：
+ 《AWS Directory Service 管理指南》**中的[什么是 Directory Service](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/what_is.html)
+ *《AWS Directory Service 管理指南》*中的[创建 AWS 托管 Active Directory](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_getting_started_create_directory.html)
+ 《AWS Directory Service 管理指南》**中的[何时创建信任关系](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_setup_trust.html)。

# 在不同的 VPC 或账户中将 Amazon FSx 与 AWS Managed Microsoft AD 结合使用
<a name="shared-mad"></a>

您可以使用 VPC 对等连接将 FSx for Windows File Serverr 文件系统加入到同一账户内不同 VPC 中的 AWS Managed Microsoft AD 目录中。您还可以使用目录共享将您的文件系统加入到不同 AWS 账户下的 AWS Managed Microsoft AD 目录中。

**注意**  
只能选择与文件系统处于相同 AWS 区域 中的 AWS Managed Microsoft AD。如果要使用跨区域 VPC 对等设置，则应使用自行管理的 Microsoft Active Directory。有关更多信息，请参阅 [使用自行管理的 Microsoft Active Directory](self-managed-AD.md)。

将文件系统加入其他 VPC 中的 AWS Managed Microsoft AD 的工作流程包括以下步骤：

1. 设置您的网络环境。

1. 共享您的目录。

1. 将您的文件系统加入共享目录。

有关更多信息，请参阅《Directory Service 管理指南》**中的[共享目录](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_directory_sharing.html)。

您可以使用 AWS Transit Gateway 或 Amazon VPC 并创建 VPC 对等连接来设置您的网络环境。此外，请确保两个 VPC 之间允许网络流量。

*中转网关*是网络中转中心，您可用它来互连 VPC 和本地网络。有关使用 VPC 中转网关的更多信息，请参阅《Amazon VPC 中转网关指南》**中的[开始使用中转网关](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-getting-started.html)。

*VPC 对等连接*是两个 VPC 之间的网络连接。使用连接，您能够使用专用 Internet 协议版本 4（IPv4）或 Internet 协议版本 6（IPv6）地址，在它们之间路由流量。可以使用 VPC 对等，在同一 AWS 区域中或在 AWS 区域之间连接 VPC。有关 VPC 对等连接的更多信息，请参阅《Amazon VPC 对等连接指南》**中的[什么是 VPC 对等连接？](https://docs.aws.amazon.com/vpc/latest/peering/Welcome.html)。

要将文件系统加入到与该文件系统使用不同账户的 AWS Managed Microsoft AD 目录时，还需要满足另一个先决条件。您还需要与另一个账户共享您的 Microsoft Active Directory 目录。要执行此操作，您可以使用 AWS 托管 Microsoft Active Directory 的目录共享功能。要了解更多信息，请参阅《AWS Directory Service 管理指南》**中的[共享目录](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ms_ad_directory_sharing.html)。

# 验证与 Active Directory 域控制器的连接
<a name="validate-ad-domain-controllers"></a>

 在创建已加入 Active Directory 的 FSx for Windows File Server 文件系统之前，请使用 Amazon FSx Active Directory 验证工具来验证与 Active Directory 域之间的连接。无论您与 FSx for Windows File Server 结合使用的是 AWS 托管 Microsoft Active Directory，还是自行管理的 Active Directory 配置，都可以使用此测试。域控制器网络连接测试（test-fsxadControllerConnection）不会对域中的每个域控制器运行整套网络连接检查。相反，应使用此测试针对一组特定的域控制器运行网络连接验证。<a name="test-ad-controller-connectivity"></a>

**验证与 Active Directory 域控制器的连接**

1. 在同一个子网中，启动一个具有相同 Amazon VPC 安全组且您要将其用于 FSx for Windows File Server 文件系统的 Amazon EC2 Windows 实例。对于多可用区部署类型，请使用首选活动文件服务器的子网。

1. 将 EC2 Windows 实例加入 Active Directory 有关更多信息，请参阅《AWS Directory Service 管理指南》**中的[手动加入 Windows 实例](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/join_windows_instance.html)。

1. 连接到您的 EC2 实例。有关详细信息，请参阅《Amazon EC2 用户指南》中的 [Connecting to Your Windows Instance](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html)**。

1. 在 EC2 实例上打开 Windows PowerShell 窗口（使用**以管理员身份运行**）。

   请使用以下测试命令测试是否已安装 Windows PowerShell 所需的 Active Directory 模块。

   

   ```
   PS C:\> Import-Module ActiveDirectory
   ```

   

   如果上一操作返回错误，请使用以下命令进行安装。

   

   ```
   PS C:\> Install-WindowsFeature RSAT-AD-PowerShell
   ```

1. 使用以下命令下载网络验证工具。

   

   ```
   PS C:\> Invoke-WebRequest "https://docs.aws.amazon.com/fsx/latest/WindowsGuide/samples/AmazonFSxADValidation.zip" -OutFile "AmazonFSxADValidation.zip"
   ```

1. 使用以下命令下载 zip 文件。

   ```
   PS C:\> Expand-Archive -Path "AmazonFSxADValidation.zip"
   ```

1. 将 AmazonFSxADValidation 模块添加到当前会话。

   ```
   PS C:\> Import-Module .\AmazonFSxADValidation
   ```

1. 设置 Active Directory 域控制器 IP 地址的值，然后使用以下命令运行连接测试：

   ```
   $ADControllerIp = '10.0.75.243'
   $Result = Test-FSxADControllerConnection -ADControllerIp $ADControllerIp
   ```

1. 以下示例所示为检索包含结果为连接测试成功的测试输出。

   ```
   PS C:\AmazonFSxADValidation> $Result
   
   Name                           Value
   ----                           -----
   TcpDetails                     {@{Port=88; Result=Listening; Description=Kerberos authentication}, @{Port=135; Resul...
   Server                         10.0.75.243
   UdpDetails                     {@{Port=88; Result=Timed Out; Description=Kerberos authentication}, @{Port=123; Resul...
   Success                        True
   
   
   PS C:\AmazonFSxADValidation> $Result.TcpDetails
   
   Port Result    Description
   ---- ------    -----------
     88 Listening Kerberos authentication
    135 Listening DCE / EPMAP (End Point Mapper)
    389 Listening Lightweight Directory Access Protocol (LDAP)
    445 Listening Directory Services SMB file sharing
    464 Listening Kerberos Change/Set password
    636 Listening Lightweight Directory Access Protocol over TLS/SSL (LDAPS)
   3268 Listening Microsoft Global Catalog
   3269 Listening Microsoft Global Catalog over SSL
   9389 Listening Microsoft AD DS Web Services, PowerShell
   ```

    以下示例所示为运行测试以及获得失败的结果。

   ```
   PS C:\AmazonFSxADValidation> $Result = Test-FSxADControllerConnection -ADControllerIp $ADControllerIp
   WARNING: TCP 9389 failed to connect. Required for Microsoft AD DS Web Services, PowerShell. 
   Verify security group and firewall settings on both client and directory controller.
   WARNING: 1 ports failed to connect to 10.0.75.243. Check pre-requisites in
   https://docs.aws.amazon.com/fsx/latest/WindowsGuide/self-managed-AD.html#self-manage-prereqs
   
   PS C:\AmazonFSxADValidation> $Result
   
   Name                           Value
   ----                           -----
   TcpDetails                     {@{Port=88; Result=Listening; Description=Kerberos authentication}, @{Port=135; Resul...
   Server                         10.0.75.243
   UdpDetails                     {@{Port=88; Result=Timed Out; Description=Kerberos authentication}, @{Port=123; Resul...
   Success                        False
   FailedTcpPorts                 {9389}
   
   
   PS C:\AmazonFSxADValidation> $Result.FailedTcpPorts
   9389
   ```
   
   Windows socket error code mapping
   
   https://msdn.microsoft.com/en-us/library/ms740668.aspx
   ```

**注意**  
作为上述过程的替代方法，您可以使用 `AWSSupport-ValidateFSxWindowsADConfig` 运行手册，验证自行管理的 Active Directory 配置。有关更多信息，请参阅《AWS Systems Manager Automation 运行手册参考》**中的 [https://docs.aws.amazon.com/systems-manager-automation-runbooks/latest/userguide/awssupport-validate-fsxwindows-adconfig.html](https://docs.aws.amazon.com/systems-manager-automation-runbooks/latest/userguide/awssupport-validate-fsxwindows-adconfig.html)。