

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# EFA 対応の FSx Lustre を使用したクラスターの作成
<a name="tutorial-efa-enabled-fsx-lustre"></a>

このチュートリアルでは、EFA 対応の FSx Lustre ファイルシステムを共有ストレージとして使用するクラスターを作成します。EFA を有効にして FSx Lustre ファイルシステムを使用すると、パフォーマンスが最大 8 倍向上します。EFA 対応ファイルシステムが必要なものかどうかを確認するには、*FSx for Lustre ユーザーガイド*」の[「EFA 対応ファイルシステムの使用](https://docs.aws.amazon.com/fsx/latest/LustreGuide/efa-file-systems.html)」を参照してください。

を使用すると AWS ParallelCluster、 AWS ParallelCluster イメージとクラスターを作成または更新したときに作成された AWS リソースに対してのみ料金が発生します。詳細については、「[AWS が使用する サービス AWS ParallelCluster](aws-services-v3.md)」を参照してください。

## 要件
<a name="tutorial-efa-enabled-fsx-lustre-requirements"></a>
+ CLI AWS [がインストールされ、設定されています](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)。
+ ParallelCluster CLI [がインストールされ、設定されています](install-v3-parallelcluster.md)。
+ クラスターにログインするための [Amazon EC2 キーペア](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)。
+ ParallelCluster CLI の実行に必要な[アクセス許可](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)を持つ IAM ロール。

## セキュリティグループを作成する
<a name="tutorial-efa-enabled-fsx-lustre-security-groups"></a>

クラスターとファイルシステムがデプロイされる同じ VPC に 2 つのセキュリティグループを作成します。1 つはクラスターノードで実行されているクライアント用、もう 1 つはファイルシステム用です。

```
# 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 の必要に応じて](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-start.html#efa-start-security)、ファイルシステムへのすべてのアウトバウンドトラフィックを許可するようにクライアントのセキュリティグループを設定します。

```
# 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 の必要に応じて](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-start.html#efa-start-security)、ファイルシステムのセキュリティグループを設定して、それ自体内のすべてのインバウンド/アウトバウンドトラフィックとクライアントからのすべてのインバウンドトラフィックを許可します。

```
# 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
```

## ファイルシステムを作成する
<a name="tutorial-efa-enabled-fsx-lustre-create-filesystem"></a>

コンピューティングノードがあるのと同じアベイラビリティーゾーン (AZ) 内にファイルシステムを作成し、 を次のコードの ID `subnet-compute-nodes` に置き換えます。これは、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 を書き留めます。チュートリアルの残りの部分では、 をこのファイルシステム ID `fs-id`に置き換えます。

## クラスターを作成する
<a name="tutorial-efa-enabled-fsx-lustre-create-cluster"></a>

1. YAML 設定ファイルに次の設定を設定した AWS ParallelCluster クラスターを作成します。

   1. Ubuntu 22.04 など、サポートされている OS に基づく AMI。

   1. コンピューティングノードは、g6.16xlarge などの [Nitro v4\$1](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html) を持つ [EFA がサポートするインスタンスタイプ](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html#efa-instance-types)を使用する必要があります。
      + コンピューティングノードは、ファイルシステムと同じ AZ に存在する必要があります。
      + コンピューティングノードでは、[Efa/Enabled](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Efa-Enabled) を true に設定する必要があります。
      + コンピューティングノードは、[OnNodeStart](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-CustomActions-OnNodeStart) カスタムアクション`configure-efa-fsx-lustre-client.sh`として設定スクリプトを実行する必要があります。このスクリプトは、[FSx の公式ドキュメント](https://docs.aws.amazon.com/fsx/latest/LustreGuide/configure-efa-clients.html)で提供されており、お客様の便宜のためにパブリックバケットで提供されています。これは、コンピューティングノードで FSx Lustre クライアントを設定して EFA を使用できるようにすることを目的としています。

1. クラスター設定ファイル を作成します`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
         CustomActions:
           OnNodeStart:
             Script: https://us-east-1-aws-parallelcluster.s3.us-east-1.amazonaws.com/scripts/fsx-lustre-efa/configure-efa-fsx-lustre-client.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 が動作していることを検証する
<a name="tutorial-efa-enabled-fsx-lustre-validate"></a>

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
```

機能が機能している場合、インターフェイスを通過するパケットの数が増加することが予想されます。