

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

# 搭配 AWS PCS 使用網路檔案系統
<a name="working-with_file-systems"></a>

您可以將網路檔案系統連接到 AWS 平行運算服務 (AWS PCS) 運算節點群組中啟動的節點，以提供可寫入和存取資料和檔案的持久性位置。您可以使用 AWS 服務提供的檔案系統，包括 [Amazon Elastic File System](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) (Amazon EFS)、[Amazon FSx for Lustre](https://docs.aws.amazon.com/fsx/latest/LustreGuide/what-is.html)、[Amazon FSx for NetApp ONTAP](https://docs.aws.amazon.com/fsx/latest/ONTAPGuide/what-is-fsx-ontap.html)、[Amazon FSx for OpenZFS](https://docs.aws.amazon.com/fsx/latest/OpenZFSGuide/what-is-fsx.html) 和 [Amazon File Cache](https://docs.aws.amazon.com/fsx/latest/FileCacheGuide/what-is.html)。您也可以使用自我管理的檔案系統，例如 NFS 伺服器。

本主題涵蓋搭配 AWS PCS 使用網路檔案系統的考量和範例。

## 使用網路檔案系統的考量事項
<a name="working-with_file-systems_considerations"></a>

各種檔案系統的實作詳細資訊不同，但有一些常見的考量。
+ 相關的檔案系統軟體必須安裝在執行個體上。例如，若要使用 Amazon FSx for Lustre，應該存在適當的Lustre套件。這可以透過將其包含在運算節點群組 AMI 中，或使用執行個體開機時執行的指令碼來完成。
+ 共用網路檔案系統和運算節點群組執行個體之間必須有網路路由。
+ 共用網路檔案系統和運算節點群組執行個體的安全群組規則必須允許連線至相關連接埠。
+ 您必須跨存取檔案系統的資源維持一致的POSIX使用者和群組命名空間。否則，在 PCS 叢集上執行的任務和互動式程序可能會遇到許可錯誤。
+ 檔案系統掛載會使用EC2啟動範本完成。掛載網路檔案系統的錯誤或逾時可能會讓執行個體無法執行任務。這可能會導致意外的成本。如需偵錯啟動範本的詳細資訊，請參閱 [搭配 AWS PCS 使用 Amazon EC2 啟動範本](working-with_launch-templates.md)。

## 網路掛載範例
<a name="working-with_file-systems_network-mount"></a>

您可以使用 Amazon EFS、Amazon FSx for Lustre、Amazon FSx for NetApp ONTAP、Amazon FSx for OpenZFS 和 Amazon File Cache 建立檔案系統。展開下面的相關區段，以查看每個網路掛載的範例。

### Amazon EFS
<a name="working-with_file-systems_network-mount_efs"></a>

**檔案系統設定**

建立 Amazon EFS 檔案系統。請確定它在您要啟動 PCS 運算節點群組執行個體的每個可用區域中都有掛載目標。同時確保每個掛載目標都與允許從 PCS 運算節點群組執行個體傳入和傳出存取的安全群組相關聯。如需詳細資訊，請參閱《*Amazon Elastic File System 使用者指南*》中的[掛載目標和安全群組](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html)。

**啟動範本**

將安全群組 （從您的檔案系統設定） 新增至您將用於運算節點群組的啟動範本。

包含使用`cloud-config`機制掛載 Amazon EFS 檔案系統的使用者資料。使用您自己的詳細資訊取代此指令碼中的下列值：
+ `{{mount-point-directory}}` – 您要掛載 Amazon EFS 之每個執行個體的路徑
+ `{{filesystem-id}}` – EFS 檔案系統的檔案系統 ID

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

packages:
  - amazon-efs-utils

runcmd:
  - mkdir -p /{{mount-point-directory}}
  - echo "{{filesystem-id}}:/ /{{mount-point-directory}} efs tls,_netdev" >> /etc/fstab
  - mount -a -t efs defaults

--==MYBOUNDARY==--
```

### Amazon FSx for Lustre
<a name="working-with_file-systems_network-mount_fsx-lustre"></a>

**檔案系統設定**

在您將使用 AWS PCS 的 VPC 中建立 FSx for Lustre 檔案系統。若要將區域間傳輸降至最低，請在相同可用區域中的子網路中部署，您將在該子網路中啟動大部分的 PCS 運算節點群組執行個體。確保檔案系統與允許從 PCS 運算節點群組執行個體傳入和傳出存取的安全群組相關聯。如需安全群組的詳細資訊，請參閱《[Amazon FSx for Lustre 使用者指南》中的使用 Amazon VPC 的檔案系統存取控制](https://docs.aws.amazon.com/fsx/latest/LustreGuide/limit-access-security-groups.html)。 * FSx *

**啟動範本**

包含用於`cloud-config`掛載 FSx for Lustre 檔案系統的使用者資料。使用您自己的詳細資訊取代此指令碼中的下列值：
+ `{{mount-point-directory}}` – 您想要掛載 FSx for Lustre 之執行個體的路徑
+ `{{filesystem-id}}` – FSx for Lustre 檔案系統的檔案系統 ID
+ `{{mount-name}}` – FSx for Lustre 檔案系統的掛載名稱
+ `{{region-code}}` – 部署 AWS 區域 FSx for Lustre 檔案系統的 （必須與 AWS PCS 系統相同）
+ （選用） `{{latest}}` – FSx for Lustre Lustre支援的任何版本

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

runcmd:
- amazon-linux-extras install -y lustre={{latest}}
- mkdir -p /{{mount-point-directory}}
- mount -t lustre {{filesystem-id}}.fsx.{{region-code}}.amazonaws.com@tcp:/{{mount-name}} /{{mount-point-directory}}

--==MYBOUNDARY==--
```

### Amazon FSx for NetApp ONTAP
<a name="working-with_file-systems_network-mount_fsx-ontap"></a>

**檔案系統設定**

 在您將使用 AWS PCS 的 VPC 中建立 Amazon FSx for NetApp ONTAP 檔案系統。若要將區域間傳輸降至最低，請在相同可用區域中的子網路中部署，您將在該子網路中啟動大部分的 AWS PCS 運算節點群組執行個體。請確定檔案系統與允許從 AWS PCS 運算節點群組執行個體傳入和傳出存取的安全群組相關聯。如需安全群組的詳細資訊，請參閱《*FSx for ONTAP 使用者指南*》中的[使用 Amazon VPC 的檔案系統存取控制](https://docs.aws.amazon.com/fsx/latest/ONTAPGuide/limit-access-security-groups.html)。

**啟動範本**

 包含用於`cloud-config`掛載 FSx for ONTAP 檔案系統根磁碟區的使用者資料。使用您自己的詳細資訊取代此指令碼中的下列值：
+ `{{mount-point-directory}}` – 您想要掛載 FSx for ONTAP 磁碟區的執行個體路徑
+ `{{svm-id}}` – FSx for ONTAP 檔案系統的 SVM ID
+ `{{filesystem-id}}` – FSx for ONTAP 檔案系統的檔案系統 ID
+ `{{region-code}}` – 部署 AWS 區域 FSx for ONTAP 檔案系統的 （必須與 AWS PCS 系統相同）
+ `{{volume-name}}` – ONTAP 磁碟區的 FSx 

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

runcmd:
- mkdir -p /{{mount-point-directory}}
- mount -t nfs {{svm-id}}.{{filesystem-id}}.fsx.{{region-code}}.amazonaws.com:/{{volume-name}} /{{mount-point-directory}}

--==MYBOUNDARY==--
```

### Amazon FSx for OpenZFS
<a name="working-with_file-systems_network-mount_openzfs"></a>

**檔案系統設定**

 在您將使用 AWS PCS 的 VPC 中建立 FSx for OpenZFS 檔案系統。若要將區域間傳輸降至最低，請在相同可用區域中的子網路中部署，您將在該子網路中啟動大部分的 AWS PCS 運算節點群組執行個體。請確定檔案系統與允許從 AWS PCS 運算節點群組執行個體傳入和傳出存取的安全群組相關聯。如需安全群組的詳細資訊，請參閱《*FSx for OpenZFS 使用者指南*》中的[使用 Amazon VPC 管理檔案系統存取](https://docs.aws.amazon.com/fsx/latest/OpenZFSGuide/limit-access-security-groups.html)。

**啟動範本**

 包含用於`cloud-config`掛載 FSx for OpenZFS 檔案系統根磁碟區的使用者資料。使用您自己的詳細資訊取代此指令碼中的下列值：
+ `{{mount-point-directory}}` – 您想要掛載 FSx for OpenZFS 共用之執行個體的路徑
+ `{{filesystem-id}}` – FSx for OpenZFS 檔案系統的檔案系統 ID
+ `{{region-code}}` – 部署 AWS 區域 FSx for OpenZFS 檔案系統的 （必須與 AWS PCS 系統相同）

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

runcmd:
- mkdir -p /{{mount-point-directory}}
- mount -t nfs -o noatime,nfsvers=4.2,sync,rsize=1048576,wsize=1048576 {{filesystem-id}}.fsx.{{region-code}}.amazonaws.com:/fsx/ /{{mount-point-directory}}

--==MYBOUNDARY==--
```

### Amazon File Cache
<a name="working-with_file-systems_network-mount_file-cache"></a>

**檔案系統設定**

在您將使用 AWS PCS 的 VPC 中建立 [Amazon File Cache](https://docs.aws.amazon.com/fsx/latest/FileCacheGuide/what-is.html)。若要將區域間傳輸降至最低，請選擇相同可用區域中的子網路，您將在其中啟動大部分的 PCS 運算節點群組執行個體。確保檔案快取與安全群組相關聯，該安全群組允許 PCS 執行個體和檔案快取之間連接埠 988 上的傳入和傳出流量。如需安全群組的詳細資訊，請參閱《[Amazon File Cache 使用者指南》中的使用 Amazon VPC 快取存取控制](https://docs.aws.amazon.com/fsx/latest/FileCacheGuide/limit-access-security-groups.html)。 **

**啟動範本**

將安全群組 （從您的檔案系統設定） 新增至您將用於運算節點群組的啟動範本。

包含用於`cloud-config`掛載 Amazon File Cache 的使用者資料。使用您自己的詳細資訊取代此指令碼中的下列值：
+ `{{mount-point-directory}}` – 您想要掛載 FSx for Lustre 之執行個體的路徑
+ `{{cache-dns-name}}` – 檔案快取的網域名稱系統 (DNS) 名稱
+ `{{mount-name}}` – 檔案快取的掛載名稱

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/cloud-config; charset="us-ascii"

runcmd:
- amazon-linux-extras install -y lustre=2.12
- mkdir -p /{{mount-point-directory}}
- mount -t lustre -o relatime,flock {{cache-dns-name}}@tcp:/{{mount-name}} /{{mount-point-directory}}

--==MYBOUNDARY==--
```