View a markdown version of this page

创建具有 EFA-enabled FSx Lustre 的集群 - Amazon ParallelCluster
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

创建具有 EFA-enabled FSx Lustre 的集群

在本教程中,您将创建一个使用 EFA-enabled FSx Lustre 文件系统作为共享存储的集群。使用启用了 EFA 的 FSx Lustre 文件系统可以将性能提高多达 8 倍。要验证 EFA-enabled 文件系统是否符合您的需求,请查看 FSx for Lu stre 用户指南中的使用 EFA-enabled 文件系统

使用时 Amazon ParallelCluster,您只需为创建或更新 Amazon ParallelCluster 映像和集群时创建的 Amazon 资源付费。有关更多信息,请参阅 Amazon 使用的服务 Amazon ParallelCluster

要求

创建安全组

在部署集群和文件系统的同一 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-id vpc-cluster \ --region region # 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-id vpc-cluster \ --region region

在本教程的其余部分中,我们将假设sg-client和分别sg-file-system是客户端和文件系统的安全组 ID。

按照 EFA 的要求,为客户端配置安全组以允许进出文件系统的所有 inbound/outbound 流量

# Allow all inbound traffic from the file system to the client aws ec2 authorize-security-group-ingress \ --group-id sg-client \ --protocol -1 \ --port -1 \ --source-group sg-file-system \ --region region # Allow all outbound traffic from the client to the file system aws ec2 authorize-security-group-egress \ --group-id sg-client \ --protocol -1 \ --port -1 \ --source-group sg-file-system \ --region region

按照 EFA 的要求,为文件系统配置安全组,使其允许其内部的所有流量以及来自客户端的所有入站流量。 inbound/outbound

# Allow all inbound traffic within this security group aws ec2 authorize-security-group-ingress \ --group-id sg-file-system \ --protocol -1 \ --port -1 \ --source-group sg-file-system \ --region region # Allow all outbound traffic within this security group aws ec2 authorize-security-group-egress \ --group-id sg-file-system \ --protocol -1 \ --port -1 \ --source-group sg-file-system \ --region region # Allow all inbound traffic from the client aws ec2 authorize-security-group-ingress \ --group-id sg-file-system \ --protocol -1 \ --port -1 \ --source-group sg-client \ --region region # Allow all outbound traffic to the client aws ec2 authorize-security-group-egress \ --group-id sg-file-system \ --protocol -1 \ --port -1 \ --source-group sg-client \ --region region

创建文件系统

在计算节点所在的同一可用区 (AZ) 内创建文件系统;并在以下代码中subnet-compute-nodes替换为其 ID。这是允许 EFA 使用您的文件系统所必需的。请注意,作为创建文件系统的一部分,我们使用 EfaEnable 属性启用 EFA。

aws fsx create-file-system \ --file-system-type LUSTRE \ --storage-capacity 38400 \ --storage-type SSD \ --subnet-ids subnet-compute-nodes \ --security-group-ids sg-file-system \ --lustre-configuration DeploymentType=PERSISTENT_2,PerUnitStorageThroughput=125,EfaEnabled=true,MetadataConfiguration={Mode=AUTOMATIC} \ --region region

记下上一个命令返回的文件系统 ID。在本教程的其余部分中,fs-id用此文件系统 ID 替换。

创建集群

  1. 使用 Amazon ParallelCluster YAML 配置文件中设置的以下配置创建集群:

    1. AMI 基于支持的操作系统,例如 Ubuntu 22.04。

    2. 计算节点必须使用支持 EFA 且具有 Nitro v4+ 的实例类型,例如 g6.16xlarge。

      • 计算节点必须位于文件系统所在的同一个可用区中。

      • 计算节点必须Efa/Enabled设置为 true。

      • 计算节点必须按照《fsX for Lustre 用户指南》中的 “配置 EFA 客户端”,将 FSx Lustre 客户端配置为使用 E F A。该指南提供了您可以下载、解压缩和运行的configure-efa-fsx-lustre-client软件包setup.sh。要将其自动应用于每个计算节点,请通过OnNodeStart自定义操作运行这些步骤,如下所示。

      • 例如your-bucket,创建文件configure-efa-fsx-lustre-client-wrapper.sh并将其上传到可从计算节点访问的存储桶。按照上面引用的 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 cp s3://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
  2. 创建集群配置文件config.yaml

    Region: region Image: Os: ubuntu2204 HeadNode: InstanceType: c5.xlarge Networking: SubnetId: subnet-xxxxxxxxxx AdditionalSecurityGroups: - sg-client Ssh: KeyName: my-ssh-key Scheduling: 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-client PlacementGroup: Enabled: false Iam: S3Access: - BucketName: your-bucket CustomActions: OnNodeStart: # Point this at the wrapper script you created and hosted (see step above). Script: s3://your-bucket/configure-efa-fsx-lustre-client-wrapper.sh SharedStorage: - 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 \ --region region

验证使用 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

如果该功能起作用,则流经该接口的数据包数量预计会增加。