

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Lustre 根 squash
<a name="root-squash"></a>

根 squash 是一種管理功能，可在目前的網路型存取控制和 POSIX 檔案許可之上新增額外的檔案存取控制層。使用根 squash 功能，您可以限制嘗試以根存取 FSx for Lustre 檔案系統的用戶端的根層級存取。

需要根使用者許可才能執行管理動作，例如管理 FSx for Lustre 檔案系統的許可。不過，根存取可為使用者提供不受限制的存取，讓他們繞過存取、修改或刪除檔案系統物件的許可檢查。使用根 squash 功能，您可以為檔案系統指定非根使用者 ID (UID) 和群組 ID (GID)，以防止未經授權的存取或刪除資料。存取檔案系統的根使用者會自動轉換為由儲存管理員所設定具有有限許可的指定低權限使用者/群組。

根 squash 功能也可讓您選擇性地提供不受根 squash 設定影響的用戶端清單。這些用戶端可以使用不受限制的權限，以根存取檔案系統。

**Topics**
+ [根 squash 的運作方式](#root-squash-overview)
+ [管理根 squash](#manage-root-squash)

## 根 squash 的運作方式
<a name="root-squash-overview"></a>

根 Squash 功能的運作方式是將根使用者的使用者 ID (UID) 和群組 ID (GID) 重新映射至Lustre系統管理員指定的 UID 和 GID。根 Squash 功能也可讓您選擇性地指定一組用戶端，其中 UID/GID 重新映射不適用。

當您建立新的 FSx for Lustre 檔案系統時，根 squash 預設為停用。您可以透過設定 FSx for Lustre 檔案系統的 UID 和 GID 根 squash 設定來啟用根 squash。UID 和 GID 值是可以從 `0`到 的整數`4294967294`：
+ UID 和 GID 的非零值會啟用根 squash。UID 和 GID 值可以不同，但每個值必須是非零值。
+ UID 和 GID 的值 `0`（零） 表示根，因此會停用根小隊。

在建立檔案系統期間，您可以使用 Amazon FSx 主控台在 Root Squash 屬性中提供**根 Squash** UID 和 GID 值，如 所示[在建立檔案系統時啟用根 squash （主控台）](#create-root-squash-console)。您也可以將 `RootSquash` 參數與 AWS CLI 或 API 搭配使用，以提供 UID 和 GID 值，如 所示[在建立檔案系統時啟用根 squash (CLI)](#create-root-squash-cli)。

或者，您也可以指定不適用根 squash NIDs 清單。用戶端 NID 是用於唯一識別用戶端Lustre的網路識別符。您可以將 NID 指定為單一地址或一組地址：
+ 單一地址是以標準 Lustre NID 格式描述，方法是指定用戶端的 IP 地址，後面接著Lustre網路 ID （例如，`10.0.1.6@tcp`)。
+ 地址範圍是使用破折號來分隔範圍 （例如，`10.0.[2-10].[1-255]@tcp`)。
+ 如果您未指定任何用戶端 NIDs，根 squash 不會有任何例外。

建立或更新檔案系統時，您可以使用 Amazon FSx 主控台中的 **Root Squash 屬性的例外**狀況來提供用戶端 NIDs 的清單。在 AWS CLI 或 API 中，使用 `NoSquashNids` 參數。如需詳細資訊，請參閱 中的程序[管理根 squash](#manage-root-squash)。

## 管理根 squash
<a name="manage-root-squash"></a>

在建立檔案系統期間，根 squash 預設為停用。您可以在從 Amazon FSx 主控台、 AWS CLI或 API 建立新的 Amazon FSx for Lustre 檔案系統時啟用根 squash。

### 在建立檔案系統時啟用根 squash （主控台）
<a name="create-root-squash-console"></a>

1. 在 [https://console.aws.amazon.com/fsx/](https://console.aws.amazon.com/fsx/)：// 開啟 Amazon FSx 主控台。

1. 請遵循*「入門*」一節[步驟 1：建立 FSx for Lustre 檔案系統](getting-started.md#getting-started-step1)中所述建立新檔案系統的程序。

1. 開啟 **Root Squash - *選用***區段。

1. 對於**根 Squash**，請提供根使用者可以存取檔案系統的使用者和群組 IDs。您可以指定 `1`- 範圍內的任何整數`4294967294`：

   1. 針對**使用者 ID**，指定要使用的根使用者的使用者 ID。

   1. 針對**群組 ID**，指定要使用之根使用者的群組 ID。

1. （選用） 針對**根 Squash 的例外**狀況，請執行下列動作：

   1. 選擇**新增用戶端地址**。

   1. 在**用戶端地址**欄位中，指定根 Squash 不適用的用戶端 IP 地址。如需 IP 地址格式的資訊，請參閱[根 squash 的運作方式](#root-squash-overview)。

   1. 視需要重複 以新增更多用戶端 IP 地址。

1. 如同建立新檔案系統一樣，完成精靈。

1. 選擇 **Review and create** (檢閱和建立)。

1. 檢閱您為 Amazon FSx for Lustre 檔案系統選擇的設定，然後選擇**建立檔案系統**。

當檔案系統**可用**時，會啟用根 squash。

### 在建立檔案系統時啟用根 squash (CLI)
<a name="create-root-squash-cli"></a>
+ 若要在啟用根 squash 的情況下建立 FSx for Lustre 檔案系統，請使用 Amazon FSx CLI 命令[https://docs.aws.amazon.com/cli/latest/reference/fsx/create-file-system.html](https://docs.aws.amazon.com/cli/latest/reference/fsx/create-file-system.html)搭配 `RootSquashConfiguration` 參數。對應的 API 操作是 [CreateFileSystem](https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateFileSystem.html)。

  針對 `RootSquashConfiguration` 參數，設定下列選項：
  + `RootSquash` – 以冒號分隔的 UID：GID 值，指定根使用者要使用的使用者 ID 和群組 ID。您可以為每個 ID 指定 `0`-`4294967294` (0 為根） 範圍內的任何整數 （例如，`65534:65534`)。
  + `NoSquashNids` – 指定根 squash 不適用的用戶端Lustre的網路識別符 (NIDs)。如需用戶端 NID 格式的資訊，請參閱 [根 squash 的運作方式](#root-squash-overview)。

  下列範例會在啟用根 squash 的情況下建立 FSx for Lustre 檔案系統：

  ```
  $ aws fsx create-file-system \
        --client-request-token CRT1234 \
        --file-system-type LUSTRE \
        --file-system-type-version 2.15 \
        --lustre-configuration "DeploymentType=PERSISTENT_2,PerUnitStorageThroughput=250,DataCompressionType=LZ4,\
            RootSquashConfiguration={RootSquash="65534:65534",\
            NoSquashNids=["10.216.123.47@tcp", "10.216.12.176@tcp"]}" \
        --storage-capacity 2400 \
        --subnet-ids subnet-123456 \
        --tags Key=Name,Value=Lustre-TEST-1 \
        --region us-east-2
  ```

成功建立檔案系統後，Amazon FSx 會將檔案系統描述傳回為 JSON，如下列範例所示。

```
{

    "FileSystems": [
        {
            "OwnerId": "111122223333",
            "CreationTime": 1549310341.483,
            "FileSystemId": "fs-0123456789abcdef0",
            "FileSystemType": "LUSTRE",
            "FileSystemTypeVersion": "2.15",
            "Lifecycle": "CREATING",
            "StorageCapacity": 2400,
            "VpcId": "vpc-123456",
            "SubnetIds": [
                "subnet-123456"
            ],
            "NetworkInterfaceIds": [
                "eni-039fcf55123456789"
            ],
            "DNSName": "fs-0123456789abcdef0.fsx.us-east-2.amazonaws.com",
            "ResourceARN": "arn:aws:fsx:us-east-2:123456:file-system/fs-0123456789abcdef0",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "Lustre-TEST-1"
                }
            ],
            "LustreConfiguration": {
                "DeploymentType": "PERSISTENT_2",
                "DataCompressionType": "LZ4",
                "PerUnitStorageThroughput": 250,
                "RootSquashConfiguration": {
                    "RootSquash": "65534:65534", 
                    "NoSquashNids": "10.216.123.47@tcp 10.216.29.176@tcp"
            }
        }
    ]
}
```

您也可以使用 Amazon FSx 主控台 AWS CLI或 API 更新現有檔案系統的根 Squash 設定。例如，您可以變更根 Squash UID 和 GID 值、新增或移除用戶端 NIDs，或停用根 Squash。

### 若要更新現有檔案系統上的根 Squash 設定 （主控台）
<a name="update-root-squash-console"></a>

1. 在 [https://console.aws.amazon.com/fsx/](https://console.aws.amazon.com/fsx/)：// 開啟 Amazon FSx 主控台。

1. 導覽至**檔案系統**，然後選擇您要管理根 squash Lustre的檔案系統。

1. 針對**動作**，選擇**更新根 squash**。或者，在**摘要**面板中，選擇檔案系統**根 Squash** 欄位旁的**更新**，以顯示**更新根 Squash 設定**對話方塊。

1. 對於**根 Squash**，更新根使用者可以存取檔案系統的使用者和群組 IDs。您可以指定 `0`- 範圍內的任何整數`4294967294`。若要停用根 squash，請為兩個 IDs 指定 `0`（零）。

   1. 針對**使用者 ID**，指定要使用的根使用者的使用者 ID。

   1. 針對**群組 ID**，指定要使用之根使用者的群組 ID。

1. 對於**根 Squash 的例外**狀況，請執行下列動作：

   1. 選擇**新增用戶端地址**。

   1. 在**用戶端地址**欄位中，指定根 squash 不適用的用戶端 IP 地址，

   1. 視需要重複 以新增更多用戶端 IP 地址。

1. 選擇**更新**。
**注意**  
如果已啟用根 squash 且您想要停用，請選擇**停用**，而不是執行步驟 4-6。

您可以在更新索引標籤的檔案系統詳細資訊頁面上監控**更新**進度。

### 更新現有檔案系統 (CLI) 上的根 Squash 設定
<a name="update-root-squash-cli"></a>

若要更新現有 FSx for Lustre 檔案系統的根 squash 設定，請使用 AWS CLI 命令 [update-file-system](https://docs.aws.amazon.com/cli/latest/reference/fsx/update-file-system.html)。對應的 API 操作是 [UpdateFileSystem](https://docs.aws.amazon.com/fsx/latest/APIReference/API_UdateFileSystem.html)。

設定下列參數：
+ 將 `--file-system-id`設定為您要更新之檔案系統的 ID。
+ 設定`--lustre-configuration RootSquashConfiguration`選項，如下所示：
  + `RootSquash` – 設定冒號分隔的 UID：GID 值，指定要使用的根使用者的使用者 ID 和群組 ID。您可以為每個 ID 指定 `0`-`4294967294` (0 為根） 範圍內的任何整數。若要停用根 squash，請`0:0`為 UID：GID 值指定 。
  + `NoSquashNids` – 指定根 squash 不適用的用戶端Lustre的網路識別符 (NIDs)。使用 `[]` 移除所有用戶端 NIDs，這表示根 squash 沒有任何例外。

此命令指定使用 `65534`做為根使用者的使用者 ID 和群組 ID 的值來啟用根 squash。

```
$ aws fsx update-file-system \
    --file-system-id fs-0123456789abcdef0 \
    --lustre-configuration RootSquashConfiguration={RootSquash="65534:65534", \
          NoSquashNids=["10.216.123.47@tcp", "10.216.12.176@tcp"]}
```

如果命令成功，Amazon FSx for Lustre 會以 JSON 格式傳回回應。

您可以在 Amazon FSx 主控台的檔案系統詳細資訊頁面**摘要**面板或 CLI 命令的回應 （同等 API 動作為 ) [https://docs.aws.amazon.com/cli/latest/reference/fsx/describe-file-systems.html](https://docs.aws.amazon.com/cli/latest/reference/fsx/describe-file-systems.html) 中檢視檔案系統的根佇列設定[https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html](https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html)。