

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Membuat cluster dengan EFA-enabled FSx Lustre
<a name="tutorial-efa-enabled-fsx-lustre"></a>

Dalam tutorial ini, Anda akan membuat cluster yang menggunakan sistem file EFA-enabled FSx Lustre sebagai penyimpanan bersama. Menggunakan sistem file FSx Lustre dengan EFA diaktifkan dapat memberikan peningkatan kinerja hingga 8x. Untuk memverifikasi apakah sistem EFA-enabled file adalah yang Anda butuhkan, lihat [Bekerja dengan sistem EFA-enabled file di Panduan](https://docs.aws.amazon.com/fsx/latest/LustreGuide/efa-file-systems.html) Pengguna *FSx for Lustre*.

Ketika Anda menggunakan AWS ParallelCluster, Anda hanya membayar untuk AWS sumber daya yang dibuat ketika Anda membuat atau memperbarui AWS ParallelCluster gambar dan cluster. Untuk informasi selengkapnya, lihat [AWS layanan yang digunakan oleh AWS ParallelCluster](aws-services-v3.md).

## Persyaratan
<a name="tutorial-efa-enabled-fsx-lustre-requirements"></a>
+  AWS CLI [diinstal dan dikonfigurasi](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
+  ParallelCluster CLI [diinstal dan dikonfigurasi](install-v3-parallelcluster.md).
+ Sebuah [key pair Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) untuk login ke cluster.
+ Peran IAM dengan [izin](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) yang diperlukan untuk menjalankan CLI ParallelCluster .

## Buat Grup Keamanan
<a name="tutorial-efa-enabled-fsx-lustre-security-groups"></a>

Buat dua grup keamanan di VPC yang sama di mana cluster dan sistem file akan digunakan: satu untuk klien yang berjalan pada node cluster dan satu untuk sistem file.

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

Dalam sisa tutorial, kita akan mengasumsikan `sg-client` dan `sg-file-system` merupakan id grup keamanan dari klien dan sistem file, masing-masing.

Konfigurasikan grup keamanan untuk klien untuk memungkinkan semua inbound/outbound lalu lintas ke dan dari sistem file, seperti yang [dipersyaratkan oleh 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}}
```

Konfigurasikan grup keamanan untuk sistem file untuk memungkinkan semua inbound/outbound lalu lintas di dalam dirinya sendiri dan semua lalu lintas masuk dari klien, seperti yang [dipersyaratkan oleh 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}}
```

## Buat sistem file
<a name="tutorial-efa-enabled-fsx-lustre-create-filesystem"></a>

Buat sistem file dalam Availability Zone (AZ) yang sama di mana node komputasi akan berada; dan ganti `{{subnet-compute-nodes}}` dengan ID-nya dalam kode berikut. Ini diperlukan untuk memungkinkan EFA bekerja dengan sistem file Anda. Perhatikan bahwa, sebagai bagian dari pembuatan sistem file, kami mengaktifkan EFA menggunakan EfaEnable properti.

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

Perhatikan id sistem file yang dikembalikan oleh perintah sebelumnya. Di sisa tutorial, ganti `{{fs-id}}` dengan id sistem file ini.

## Buat cluster
<a name="tutorial-efa-enabled-fsx-lustre-create-cluster"></a>

1. Buat cluster dengan konfigurasi berikut yang diatur dalam file konfigurasi AWS ParallelCluster YAMAL:

   1. AMI berdasarkan OS yang didukung, seperti Ubuntu 22.04.

   1. Node komputasi harus menggunakan [tipe instans yang didukung EFA yang](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html#efa-instance-types) memiliki [Nitro v4\+](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html), seperti g6.16xlarge.
      + Node komputasi harus berada di AZ yang sama di mana sistem file berada.
      + Node komputasi harus [Efa/Enabled](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Efa-Enabled)disetel ke true.
      + *Node komputasi harus mengkonfigurasi klien FSx Lustre untuk menggunakan EFA dengan [mengikuti Mengonfigurasi klien EFA di](https://docs.aws.amazon.com/fsx/latest/LustreGuide/configure-efa-clients.html) FSx for Lustre User Guide.* Panduan itu menyediakan `configure-efa-fsx-lustre-client` paket, yang Anda unduh, ekstrak, dan jalankan`setup.sh`. Untuk menerapkannya secara otomatis pada setiap node komputasi, jalankan langkah-langkah ini dari tindakan [OnNodeStart](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-CustomActions-OnNodeStart)kustom, seperti yang ditunjukkan di bawah ini.
      + Buat file `configure-efa-fsx-lustre-client-wrapper.sh` dan unggah ke bucket, misalnya`your-bucket`, yang dapat dijangkau dari node komputasi. Mengikuti langkah-langkah dalam dokumentasi FSx yang direferensikan di atas, pembungkus melakukan hal yang setara dengan:

        ```
        #!/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. Buat file konfigurasi cluster`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}}
   ```

   Kemudian buat cluster menggunakan konfigurasi itu:

   ```
   pcluster create-cluster \
       --cluster-name fsx-efa-tutorial \
       --cluster-configuration config.yaml \
       --region {{region}}
   ```

## Validasi FSx dengan EFA berfungsi
<a name="tutorial-efa-enabled-fsx-lustre-validate"></a>

Untuk memverifikasi bahwa lalu lintas jaringan Lustre menggunakan EFA, gunakan `lnetctl` alat Lustre yang dapat menunjukkan lalu lintas jaringan untuk antarmuka jaringan tertentu. Untuk tujuan ini, jalankan perintah berikut dalam node komputasi:

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

Jika fitur ini berfungsi, jumlah paket yang mengalir melalui antarmuka diperkirakan akan meningkat.