本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用啟用 EFA 的 FSx Lustre 建立叢集
在本教學課程中,您將建立叢集,使用啟用 EFA 的 FSx Lustre 檔案系統做為共用儲存。在啟用 EFA 的情況下使用 FSx Lustre 檔案系統,可將效能提升高達 8 倍。若要驗證已啟用 EFA 的檔案系統是否為您需要的檔案系統,請參閱《FSx for Lustre 使用者指南》中的使用已啟用 EFA 的檔案系統。
使用 時 AWS ParallelCluster,您只需為建立或更新 AWS ParallelCluster 映像和叢集時建立 AWS 的資源付費。如需詳細資訊,請參閱AWS 使用的 服務 AWS ParallelCluster。
需求
-
已安裝並設定 AWS CLI。
-
已安裝並設定 ParallelCluster CLI。
-
用於登入叢集的 Amazon EC2 金鑰對。
-
具有執行 ParallelCluster CLI 所需許可的 IAM 角色。
建立安全群組
在將部署叢集和檔案系統的相同 VPC 中建立兩個安全群組:一個用於叢集節點上執行的用戶端,另一個用於檔案系統。
# Create security group for the FSx client aws ec2 create-security-group \ --group-name Fsx-Client-SecurityGroup \ --description "Allow traffic for the FSx Lustre client" \ --vpc-idvpc-cluster\ --regionregion# Create security group for the FSx file system aws ec2 create-security-group \ --group-name Fsx-FileSystem-SecurityGroup \ --description "Allow traffic for the FSx Lustre File System" \ --vpc-idvpc-cluster\ --regionregion
在教學課程的其餘部分中,我們將假設 sg-client和 分別sg-file-system是用戶端和檔案系統的安全群組 ID。
設定用戶端的安全群組,以允許 EFA 要求的所有傳入/傳出流量進出檔案系統。
# Allow all inbound traffic from the file system to the client aws ec2 authorize-security-group-ingress \ --group-idsg-client\ --protocol -1 \ --port -1 \ --source-groupsg-file-system\ --regionregion# Allow all outbound traffic from the client to the file system aws ec2 authorize-security-group-egress \ --group-idsg-client\ --protocol -1 \ --port -1 \ --source-groupsg-file-system\ --regionregion
根據 EFA 的要求,設定檔案系統的安全群組,以允許其本身的所有傳入/傳出流量,以及來自用戶端的所有傳入流量。
# Allow all inbound traffic within this security group aws ec2 authorize-security-group-ingress \ --group-idsg-file-system\ --protocol -1 \ --port -1 \ --source-groupsg-file-system\ --regionregion# Allow all outbound traffic within this security group aws ec2 authorize-security-group-egress \ --group-idsg-file-system\ --protocol -1 \ --port -1 \ --source-groupsg-file-system\ --regionregion# Allow all inbound traffic from the client aws ec2 authorize-security-group-ingress \ --group-idsg-file-system\ --protocol -1 \ --port -1 \ --source-groupsg-client\ --regionregion# Allow all outbound traffic to the client aws ec2 authorize-security-group-egress \ --group-idsg-file-system\ --protocol -1 \ --port -1 \ --source-groupsg-client\ --regionregion
建立檔案系統
在運算節點所在的相同可用區域 (AZ) 內建立檔案系統;並在下列程式碼中以其 ID 取代 。這是允許 EFA 與您的檔案系統搭配使用的必要項目。請注意,在建立檔案系統的過程中,我們使用 EfaEnable 屬性啟用 EFA。subnet-compute-nodes
aws fsx create-file-system \ --file-system-type LUSTRE \ --storage-capacity 38400 \ --storage-type SSD \ --subnet-idssubnet-compute-nodes\ --security-group-idssg-file-system\ --lustre-configuration DeploymentType=PERSISTENT_2,PerUnitStorageThroughput=125,EfaEnabled=true,MetadataConfiguration={Mode=AUTOMATIC} \ --regionregion
請記下上一個命令傳回的檔案系統 ID。在教學課程的其餘部分中,使用此檔案系統 ID 取代 。fs-id
建立叢集
-
使用 YAML 組態檔案中設定的 AWS ParallelCluster 下列組態建立叢集:
-
以支援的作業系統為基礎的 AMI,例如 Ubuntu 22.04。
-
運算節點必須使用具有 Nitro v4+ 的 EFA 支援的執行個體類型,例如 g6.16xlarge。
-
運算節點必須位於檔案系統所在的相同 AZ 中。
-
運算節點必須將 Efa/Enabled 設定為 true。
-
運算節點必須依照 FSx for Lustre 使用者指南中的 FSx設定 EFA 用戶端,將 FSx Lustre 用戶端設定為使用 EFA。本指南提供
configure-efa-fsx-lustre-client套件,供您下載、擷取並使用 執行setup.sh。若要自動將其套用至每個運算節點,請從 OnNodeStart 自訂動作執行這些步驟,如下所示。 -
建立 檔案並將其
configure-efa-fsx-lustre-client-wrapper.sh上傳至可從運算節點連線的儲存貯體your-bucket,例如 。遵循上述 FSx 文件中的步驟,包裝函式會執行相當於:#!/bin/bash set -euo pipefail # Download the FSx Lustre EFA client configuration package. # See: https://docs.aws.amazon.com/fsx/latest/LustreGuide/configure-efa-clients.html # Replace the source below with a location reachable from your compute nodes # (for example, your own S3 bucket populated from the FSx documentation package). cd /tmp aws s3 cps3://your-bucket/configure-efa-fsx-lustre-client.zip. unzip -o configure-efa-fsx-lustre-client.zip cd configure-efa-fsx-lustre-client # Configure the FSx Lustre client to use EFA. ./setup.sh
-
-
-
建立叢集組態檔案
config.yaml:Region:regionImage: Os: ubuntu2204 HeadNode: InstanceType: c5.xlarge Networking: SubnetId:subnet-xxxxxxxxxxAdditionalSecurityGroups: -sg-clientSsh: KeyName:my-ssh-keyScheduling: Scheduler: slurm SlurmQueues: - Name: q1 ComputeResources: - Name: cr1 Instances: - InstanceType: g6.16xlarge MinCount: 1 MaxCount: 3 Efa: Enabled: true Networking: SubnetIds: -subnet-xxxxxxxxxx# Subnet in the same AZ where the file system is AdditionalSecurityGroups: -sg-clientPlacementGroup: Enabled: false Iam: S3Access: - BucketName:your-bucketCustomActions: OnNodeStart: # Point this at the wrapper script you created and hosted (see step above). Script:s3://your-bucket/configure-efa-fsx-lustre-client-wrapper.shSharedStorage: - MountDir: /fsx Name: my-fsxlustre-efa-external StorageType: FsxLustre FsxLustreSettings: FileSystemId:fs-id然後使用該組態建立叢集:
pcluster create-cluster \ --cluster-name fsx-efa-tutorial \ --cluster-configuration config.yaml \ --regionregion
使用 EFA 驗證 FSx 正在運作
若要驗證 Lustre 網路流量是否使用 EFA,請使用 Lustre lnetctl工具來顯示指定網路介面的網路流量。為此,請在運算節點中執行下列命令:
# Take note of the number of packets flowing through the interface, # which are specified in statistics:send_count and statistics:recv_count sudo lnetctl net show --net efa -v # Generate traffic to the file system echo 'Hello World' > /fsx/hello-world.txt # Take note of the number of packets flowing through the interface, # which are specified in statistics:send_count and statistics:recv_count sudo lnetctl net show --net efa -v
如果功能正常運作,流經界面的封包數量預期會增加。