

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

# 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 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 の必要に応じて](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\+](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 に設定する必要があります。
      + コンピューティングノードは、FSx for Lustre ユーザーガイド」の「EFA クライアント[の設定」に従って、EFA](https://docs.aws.amazon.com/fsx/latest/LustreGuide/configure-efa-clients.html) を使用するように FSx Lustre クライアントを設定する必要があります。 *FSx * このガイドでは、 でダウンロード、抽出、実行する `configure-efa-fsx-lustre-client`パッケージを提供しています`setup.sh`。すべてのコンピューティングノードに自動的に適用するには、以下に示すように、[OnNodeStart](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-CustomActions-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
        ```

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
         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 が動作していることを検証する
<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
```

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