

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

# 管理 SVM Active Directory 配置
<a name="manage-svm-ad-config"></a>

本节介绍如何使用 AWS 管理控制台、 AWS CLI、 FSx API 和 ONTAP CLI 来执行以下操作：
+ 将现有 SVM 加入 Active Directory
+ 修改现有的 SVM 活动目录配置
+  SVMs 从活动目录中删除

要从 Active Directory 中删除 SVM，必须使用 NetApp ONTAP CLI。

**Topics**
+ [使用 AWS 管理控制台、 AWS CLI 和 API 加入 SVMs 活动目录](join-svm-to-ad.md)
+ [使用 AWS 管理控制台、 AWS CLI和 API 更新现有 SVM Active Directory 配置](update-svm-ad-config.md)
+ [使用 CLI 更新 SVM 活动目录配置 NetApp](manage-svm-ad-config-ontap-cli.md)

# 使用 AWS 管理控制台、 AWS CLI 和 API 加入 SVMs 活动目录
<a name="join-svm-to-ad"></a>

可以使用以下过程将现有 SVM 加入 Active Directory。在此过程中，SVM 还*没有*加入 Active Directory。

**将 SVM 加入 Active Directory（AWS 管理控制台）**

1. 打开亚马逊 FSx 控制台，网址为[https://console.aws.amazon.com/fsx/](https://console.aws.amazon.com/fsx/)。

1. 选择要加入活动目录的 SVM：
   + 在左侧导航窗格中，选择**文件系统**，然后选择包含要更新的 SVM 的 ONTAP 文件系统。
   + 选择**存储虚拟机**选项卡。

     –或–
   + 要显示所有可用虚拟机的列表 SVMs，请在左侧导航窗格中展开 **ONTAP**，然后选择**存储虚拟机**。中将显示您的账户 SVMs 中所有内容 AWS 区域 的列表。

   从列表中选择要加入 Active Directory 的 SVM。

1. 在 SVM **摘要**面板的右上角，选择**操作** > **加入/更新 Active Directory**。此时显示**将 SVM 加入 Active Directory** 窗口。

1. 输入要将 SVM 加入其中的 Active Directory 的以下信息：
   + 为 SVM 创建的 Active Directory 计算机对象的 **NetBIOS 名称**。这是 Active Directory 中 SVM 的名称，其在 Active Directory 中必须唯一。不要使用主域的 NetBIOS 名称。NetBIOS 名称不能超过 15 个字符。
   + Active Directory 域的**完全限定域名（FQDN）**。域名不能超过 255 个字符。
   + **DNS 服务器 IP 地址**-您的域名的 DNS 服务器的 IPv4 或 IPv6 地址。
   + **服务账户凭证**：选择如何提供服务账户凭证：
     + **选项 1**： AWS Secrets Manager 秘密 ARN-包含您的 Active Directory 域上服务帐户的用户名和密码的密钥。有关更多信息，请参阅 [使用存储活动目录凭证 AWS Secrets Manager](self-managed-AD-best-practices.md#bp-store-ad-creds-using-secret-manager)。
     + **选项 2**：纯文本凭证
       + **服务账户用户名**：现有 Microsoft Active Directory 中服务账户的用户名。请勿包含域前缀或后缀。例如，对于 `EXAMPLE\ADMIN`，仅使用 `ADMIN`。
       + **服务账户密码** – 服务账户的密码。
       + **确认密码** – 服务账户的密码。
     + **在 Secrets Manager 中管理**（默认）：提供包含服务账户凭证的 Secrets Manager 密钥的 ARN。密钥必须包含键值对 `CUSTOMER_MANAGED_ACTIVE_DIRECTORY_USERNAME` 和 `CUSTOMER_MANAGED_ACTIVE_DIRECTORY_PASSWORD`。
     + （可选）**组织单元（OU）**：要将 SVM 加入到的组织单元的可分辨路径名称。
     + **委托文件系统管理员组** – Active Directory 中可以管理您的文件系统的组的名称。

       如果您正在使用 AWS Managed Microsoft AD，则必须指定一个群组，例如 AWS 委派 FSx管理员、 AWS 授权管理员或具有向 OU 委派权限的自定义群组。

       如果您要加入自行管理的活动目录，请在活动目录中使用该组的名称。默认组为 `Domain Admins`。

1. 选择**加入 Active Directory**，使用您提供的配置将 SVM 加入 Active Directory。

**将 SVM 加入活动目录 (AWS CLI)**
+ 要将 fo FSx r ONTAP SVM 加入活动目录，请使用 CL [update-storage-virtual-machine](https://docs.aws.amazon.com/cli/latest/reference/fsx/update-storage-virtual-machine.html)I 命令（或等效[UpdateStorageVirtualMachine](https://docs.aws.amazon.com/fsx/latest/APIReference/API_UpdateStorageVirtualMachine.html)的 API 操作），如以下示例所示。

  ```
  aws fsx update-storage-virtual-machine \
    --storage-virtual-machine-id svm-abcdef0123456789a\
    --active-directory-configuration SelfManagedActiveDirectoryConfiguration='{DomainName="corp.example.com", \
      OrganizationalUnitDistinguishedName="OU=FileSystems,DC=corp,DC=example,DC=com",\
      FileSystemAdministratorsGroup="FSxAdmins",UserName="FSxService",\
      Password="password", \
      DnsIps=["10.0.1.18"]}',NetBiosName=amznfsx12345
  ```

  成功创建存储虚拟机后，Amazon 以 JSON 格式 FSx 返回其描述，如以下示例所示。

  ```
  {
    "StorageVirtualMachine": {
      "ActiveDirectoryConfiguration": {
        "NetBiosName": "amznfsx12345",
        "SelfManagedActiveDirectoryConfiguration": {
          "UserName": "Admin",
          "DnsIps": [
            "10.0.1.3",
            "10.0.91.97"
          ],
          "OrganizationalUnitDistinguishedName": "OU=Computers,OU=customer-ad,DC=customer-ad,DC=example,DC=com",
          "DomainName": "customer-ad.example.com"
        }
      }
      "CreationTime": 1625066825.306,
      "Endpoints": {
        "Management": {
          "DnsName": "svm-abcdef0123456789a.fs-0123456789abcdef0.fsx.us-east-1.amazonaws.com",
          "IpAddressses": ["198.19.0.4"]    
        },
        "Nfs": {
          "DnsName": "svm-abcdef0123456789a.fs-0123456789abcdef0.fsx.us-east-1.amazonaws.com",
          "IpAddressses": ["198.19.0.4"]    
        },
        "Smb": {
          "DnsName": "amznfsx12345",
          "IpAddressses": ["198.19.0.4"]        
        },
        "SmbWindowsInterVpc": {
          "IpAddressses": ["198.19.0.5", "198.19.0.6"]    
        },
        "Iscsi": {
          "DnsName": "iscsi.svm-abcdef0123456789a.fs-0123456789abcdef0.fsx.us-east-1.amazonaws.com",
          "IpAddressses": ["198.19.0.7", "198.19.0.8"]    
        }
      },
      "FileSystemId": "fs-0123456789abcdef0",
      "Lifecycle": "CREATED",
      "Name": "vol1",
      "ResourceARN": "arn:aws:fsx:us-east-1:123456789012:storage-virtual-machine/fs-0123456789abcdef0/svm-abcdef0123456789a",
      "StorageVirtualMachineId": "svm-abcdef0123456789a",
      "Subtype": "default",
      "Tags": [],
  
    }
  }
  ```

# 使用 AWS 管理控制台、 AWS CLI和 API 更新现有 SVM Active Directory 配置
<a name="update-svm-ad-config"></a>

可以使用以下过程更新已加入 Active Directory 的 SVM 的 Active Directory 配置。

**更新 SVM Active Directory 配置（AWS 管理控制台）**

1. 打开亚马逊 FSx 控制台，网址为[https://console.aws.amazon.com/fsx/](https://console.aws.amazon.com/fsx/)。

1. 按如下所示方法选择要更新的 SVM：
   + 在左侧导航窗格中，选择**文件系统**，然后选择包含要更新的 SVM 的 ONTAP 文件系统。
   + 选择**存储虚拟机**选项卡。

     –或–
   + 要显示所有 SVMs 可用虚拟机的列表，请在左侧导航窗格中展开 **ONTAP**，然后选择**存储虚拟机**。

   从列表中选择要更新的 SVM。

1. 在 SVM **摘要**面板上，选择**操作** > **加入/更新 Active Directory**。此时将显示**更新 SVM Active Directory 配置**窗口。

1. 可以在此窗口中更新以下 Active Directory 配置属性。
   + **DNS 服务器 IP 地址**-您的域名的 DNS 服务器的 IPv4 或 IPv6 地址。
   + **服务账户凭证**：选择如何提供服务账户凭证：
     + **选项 1**： AWS Secrets Manager 秘密 ARN-包含您的 Active Directory 域上服务帐户的用户名和密码的密钥。有关更多信息，请参阅 [使用存储活动目录凭证 AWS Secrets Manager](self-managed-AD-best-practices.md#bp-store-ad-creds-using-secret-manager)。
     + **选项 2**：纯文本凭证
       + **服务账户用户名**：现有 Microsoft Active Directory 中服务账户的用户名。请勿包含域前缀或后缀。例如，对于 `EXAMPLE\ADMIN`，仅使用 `ADMIN`。
       + **服务账户密码** – 服务账户的密码。
       + **确认密码** – 服务账户的密码。

1. 输入更新后，选择**更新 Active Directory** 进行更改。

可以使用以下过程更新已加入 Active Directory 的 SVM 的 Active Directory 配置。

**更新 SVM Active Directory 配置（AWS CLI）**
+ 要使用 AWS CLI 或 API 更新 SVM 的 Active Directory 配置，请使用 [update-storage-virtual-machine](https://docs.aws.amazon.com/cli/latest/reference/fsx/update-storage-virtual-machine.html)CLI 命令（或等效[UpdateStorageVirtualMachine](https://docs.aws.amazon.com/fsx/latest/APIReference/API_UpdateStorageVirtualMachine.html)的 API 操作），如以下示例所示。

  ```
  aws fsx update-storage-virtual-machine \
      --storage-virtual-machine-id svm-abcdef0123456789a\
      --active-directory-configuration \
      SelfManagedActiveDirectoryConfiguration='{UserName="FSxService",\
      Password="password", \
      DnsIps=["10.0.1.18"]}'
  ```

# 使用 CLI 更新 SVM 活动目录配置 NetApp
<a name="manage-svm-ad-config-ontap-cli"></a>

您可以使用 NetApp ONTAP CLI 将您的 SVM 加入和取消加入活动目录，也可以修改现有 SVM 活动目录配置。

## 使用 ONTAP API 将 SVM 加入 Active Directory
<a name="using-ontap-cli-to-connect-to-ad"></a>

您可以使用 ONTAP CLI SVMs 将现有目录加入活动目录，如以下过程所述。即使 SVM 已经加入 Active Directory，也可以执行此过程。

1. 要访问 ONTAP CLI，请运行以下命令在 Amazon FSx for NetApp ONTAP 文件系统或 SVM 的管理端口上建立 SSH 会话。将 `management_endpoint_ip` 替换为文件系统管理端口的 IP 地址。

   ```
   [~]$ ssh fsxadmin@management_endpoint_ip
   ```

   有关更多信息，请参阅 [使用 ONTAP CLI 管理文件系统](managing-resources-ontap-apps.md#fsxadmin-ontap-cli)。

1.  通过提供完整的目录 DNS 名称（`corp.example.com`）和至少一个 DNS 服务器 IP 地址，为 Active Directory 创建 DNS 条目。

   ```
   ::>vserver services name-service dns create -vserver svm_name -domains corp.example.com -name-servers dns_ip_1, dns_ip_2 
   ```

   要验证与 DNS 服务器的连接，请运行以下命令。*svm\$1name*用您自己的信息替换。

   ```
   FsxId0ae30e5b7f1a50b6a::>vserver services name-service dns check -vserver svm_name 
   
                                 Name Server
   Vserver       Name Server     Status       Status Details
   ------------- --------------- ------------ --------------------------
   svm_name      172.31.14.245   up           Response time (msec): 0
   svm_name      172.31.25.207   up           Response time (msec): 1
   2 entries were displayed.
   ```

1. 要将 SVM 加入 Active Directory，请运行以下命令。请注意，必须指定 Active Directory 中尚不存在的 `computer_name`，并为 `-domain` 提供目录 DNS 名称。对于`-OU`，输入您希望 SVM 加入的，以及 DC 格式的完整 DNS 名称。 OUs 

   ```
   ::>vserver cifs create -vserver svm_name -cifs-server computer_name -domain corp.example.com -OU OU=Computers,OU=example,DC=corp,DC=example,DC=com
   ```

   要验证 Active Directory 连接的状态，请运行以下命令：

   ```
   ::>vserver cifs check -vserver svm_name
                                 
                 Vserver : svm_name
                       Cifs NetBIOS Name : svm_netBIOS_name
                             Cifs Status : Running
                                    Site : Default-First-Site-Name
   Node Name       DC Server Name  DC Server IP    Status   Status Details
   --------------- --------------  --------------- ------   --------------
   FsxId0ae30e5b7f1a50b6a-01 
                   corp.example.com  
                                   172.31.14.245   up       Response time (msec): 5
   FsxId0ae30e5b7f1a50b6a-02 
                   corp.example.com  
                                   172.31.14.245   up       Response time (msec): 20
   2 entries were displayed.
   ```

1. 如果此次加入后无法访问共享，请确定用于访问共享的账户是否具有权限。例如，如果您在托管 Active Directory 中使用默认`Admin`帐户（委 AWS 托管理员），则必须在 ONTAP 中运行以下命令。`netbios_domain` 与您的 Active Directory 的域名相对应（对于 `corp.example.com`，此处使用的 `netbios_domain` 是 `example`）。

   ```
   FsxId0123456789a::>vserver cifs users-and-groups local-group add-members -vserver svm_name -group-name BUILTIN\Administrators -member-names netbios_domain\admin
   ```

## 使用 ONTAP CLI 修改 Active Directory 配置
<a name="using-ontap-cli-to-modify-ad"></a>

可以使用 ONTAP CLI 修改现有 Active Directory 配置。 

1. 要访问 ONTAP CLI，请运行以下命令在 Amazon FSx for NetApp ONTAP 文件系统或 SVM 的管理端口上建立 SSH 会话。将 `management_endpoint_ip` 替换为文件系统管理端口的 IP 地址。

   ```
   [~]$ ssh fsxadmin@management_endpoint_ip
   ```

   有关更多信息，请参阅 [使用 ONTAP CLI 管理文件系统](managing-resources-ontap-apps.md#fsxadmin-ontap-cli)。

1. 运行以下命令，暂时关闭 SVM 的 CIFS 服务器： 

   ```
   FsxId0123456789a::>vserver cifs modify -vserver svm_name -status-admin down
   ```

1. 如果需要修改 Active Directory 的 DNS 条目，请运行以下命令： 

   ```
   ::>vserver services name-service dns modify -vserver svm_name -domains corp.example.com -name-servers dns_ip_1,dns_ip_2
   ```

   可以使用 `vserver services name-service dns check -vserver svm_name` 命令验证与 Active Directory 的 DNS 服务器的连接状态。

   ```
   ::>vserver services name-service dns check -vserver svm_name
                                 Name Server
   Vserver       Name Server     Status       Status Details
   ------------- --------------- ------------ --------------------------
   svmciad       dns_ip_1        up           Response time (msec): 1
   svmciad       dns_ip_2        up           Response time (msec): 1
   2 entries were displayed.
   ```

1. 如果需要修改 Active Directory 配置本身，则可以使用以下命令更改现有字段，并替换以下项：
   + *computer\$1name*，如果你想修改 SVM 的 NetBIOS（计算机帐户）名称。
   + *domain\$1name*，如果你想修改域的名称。这应与本部分步骤 3 中所述的 DNS 域条目相对应（`corp.example.com`）。
   + `organizational_unit`，如果要修改 OU（`OU=Computers,OU=example,DC=corp,DC=example,DC=com`）。

   您需要重新输入用于将此设备加入 Active Directory 的 Active Directory 凭证。

   ```
   ::>vserver cifs modify -vserver svm_name -cifs-server computer_name -domain domain_name -OU organizational_unit
   ```

   可以使用 `vserver cifs check -vserver svm_name` 命令验证 Active Directory 连接的连接状态。

1. 完成 Active Directory 和 DNS 配置修改后，运行以下命令，恢复 CIFS 服务器：

   ```
   ::>vserver cifs modify -vserver svm_name -status-admin up
   ```

## 使用 ONTAP CLI 从 SVM 取消加入活动目录 NetApp
<a name="using-ontap-cli-to-unjoin-ad"></a>

也可以按照以下步骤使用 NetApp ONTAP CLI 取消您的 SVM 与 Active Directory 的加入：

1. 要访问 ONTAP CLI，请运行以下命令在 Amazon FSx for NetApp ONTAP 文件系统或 SVM 的管理端口上建立 SSH 会话。将 `management_endpoint_ip` 替换为文件系统管理端口的 IP 地址。

   ```
   [~]$ ssh fsxadmin@management_endpoint_ip
   ```

   有关更多信息，请参阅 [使用 ONTAP CLI 管理文件系统](managing-resources-ontap-apps.md#fsxadmin-ontap-cli)。

1. 运行以下命令，删除将您的设备从 Active Directory 取消加入的 CIFS 服务器。要使 ONTAP 删除 SVM 的计算机账户，请提供最初用于将 SVM 加入 Active Directory 的凭证。

   ```
   FsxId0123456789a::>vserver cifs modify -vserver svm_name -status-admin down
   ```

1. 如果需要修改 Active Directory 的 DNS 条目，请运行以下命令： 

   ```
   FsxId0123456789a::vserver cifs delete -vserver svm_name
   
   In order to delete an Active Directory machine account for the CIFS server, you must supply the name and password of a Windows account with
   sufficient privileges to remove computers from the "CORP.ADEXAMPLE.COM" domain. 
   
   Enter the user name: user_name
   
   Enter the password: 
   
   Warning: There are one or more shares associated with this CIFS server
            Do you really want to delete this CIFS server and all its shares? {y|n}: y
   ```

1. 运行以下命令，删除 Active Directory 的 DNS 服务器：

   ```
   ::vserver services name-service dns delete -vserver svm_name
   ```

   如果显示类似以下内容的警告（指明应将 `dns` 作为 `ns-switch` 删除），并且您不打算将此设备重新加入 Active Directory，则可以删除 `ns-switch` 条目。

   ```
   Warning: "DNS" is present as one of the sources in one or more ns-switch databases but no valid DNS configuration was found for Vserver
            "svm_name". Remove "DNS" from ns-switch using the "vserver services name-service ns-switch" command. Configuring "DNS" as a source
            in the ns-switch setting when there is no valid configuration can cause protocol access issues.
   ```

1. （可选）运行以下命令，删除 `dns` 的 `ns-switch` 条目。验证源顺序，然后删除 `hosts` 数据库的 `dns` 条目，即修改 `sources`，使其仅包含列出的其他源。在此示例中，唯一的其他源是 `files`。

   ```
   ::>vserver services name-service ns-switch show -vserver svm_name -database hosts
   
                        Vserver: svm_name
   Name Service Switch Database: hosts
      Name Service Source Order: files, dns
   ```

   ```
   ::>vserver services name-service ns-switch modify -vserver svm_name -database hosts -sources files
   ```

1.  （可选）删除 `dns` 条目，即修改数据库主机的 `sources` 以仅包含 `files`。

   ```
   ::>vserver services name-service ns-switch modify -vserver svm_name -database hosts -sources files
   ```