

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

# Creación de un clúster con un Lustre habilitado para EFA FSx
<a name="tutorial-efa-enabled-fsx-lustre"></a>

En este tutorial, creará un clúster que utilice un sistema de archivos FSx Lustre compatible con EFA como almacenamiento compartido. El uso de un sistema de archivos FSx Lustre con EFA habilitado puede aumentar el rendimiento hasta 8 veces. *Para comprobar si lo que necesita es un sistema de archivos compatible con EFA, consulte [Trabajar con sistemas de archivos compatibles con EFA en la Guía del usuario](https://docs.aws.amazon.com/fsx/latest/LustreGuide/efa-file-systems.html) de Lustre. FSx *

Cuando lo usa AWS ParallelCluster, solo paga por AWS los recursos que se crean al crear o actualizar imágenes y clústeres. AWS ParallelCluster Para obtener más información, consulte [AWS servicios utilizados por AWS ParallelCluster](aws-services-v3.md).

## Requisitos
<a name="tutorial-efa-enabled-fsx-lustre-requirements"></a>
+ La AWS CLI está [instalada y configurada](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
+ La ParallelCluster CLI está [instalada y configurada](install-v3-parallelcluster.md).
+ Un [par de claves de Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) para iniciar sesión en el clúster.
+ Un rol de IAM con los [permisos](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) necesarios para ejecutar la ParallelCluster CLI.

## Creación de los grupos de seguridad
<a name="tutorial-efa-enabled-fsx-lustre-security-groups"></a>

Cree dos grupos de seguridad en la misma VPC donde se implementarán el clúster y el sistema de archivos: uno para el cliente que se ejecuta en los nodos del clúster y otro para el sistema de archivos.

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

En el resto del tutorial, `sg-client` asumiremos que `sg-file-system` son los identificadores de los grupos de seguridad del cliente y del sistema de archivos, respectivamente.

Configure el grupo de seguridad del cliente para permitir que todo el tráfico saliente llegue al sistema de archivos, según lo [exige la 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
```

Configure el grupo de seguridad del sistema de archivos para permitir todo el inbound/outbound tráfico interno y todo el tráfico entrante del cliente, según lo [exija](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-start.html#efa-start-security) la EFA. 

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

## Cree el sistema de archivos
<a name="tutorial-efa-enabled-fsx-lustre-create-filesystem"></a>

Cree el sistema de archivos en la misma zona de disponibilidad (AZ) en la que estarán los nodos de procesamiento y `subnet-compute-nodes` sustitúyalo por su ID en el código siguiente. Esto es necesario para permitir que la EFA funcione con su sistema de archivos. Tenga en cuenta que, como parte de la creación del sistema de archivos, habilitamos el EFA mediante la EfaEnable propiedad.

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

Tome nota del identificador del sistema de archivos devuelto por el comando anterior. En el resto del tutorial, `fs-id` sustitúyalo por este identificador del sistema de archivos.

## Cree el clúster
<a name="tutorial-efa-enabled-fsx-lustre-create-cluster"></a>

1. Cree el clúster con las siguientes configuraciones establecidas en el archivo de configuración AWS ParallelCluster YAML:

   1. AMI basada en un sistema operativo compatible, como Ubuntu 22.04.

   1. Los nodos de cómputo deben usar un [tipo de instancia compatible con EFA](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html#efa-instance-types) que tenga [Nitro v4\$1](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html), como la g6.16xlarge.
      + Los nodos de cómputo deben estar en la misma zona de disponibilidad en la que se encuentra el sistema de archivos.
      + Los nodos de cómputo deben tener el valor [Efa/Enabled](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-ComputeResources-Efa-Enabled) establecido en true.
      + Los nodos de cómputo deben ejecutar el script de configuración `configure-efa-fsx-lustre-client.sh` como una acción [OnNodeStart](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-CustomActions-OnNodeStart)personalizada. El script, que se incluye en la [documentación FSx oficial](https://docs.aws.amazon.com/fsx/latest/LustreGuide/configure-efa-clients.html) y se ofrece en nuestra sección pública para su comodidad, tiene por objeto configurar el cliente FSx Lustre en los nodos de cómputo para que puedan utilizar EFA.

1. Cree un archivo de configuración de clústeres: `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
   ```

   A continuación, cree un clúster con esa configuración:

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

## Validar FSx con EFA funciona
<a name="tutorial-efa-enabled-fsx-lustre-validate"></a>

Para comprobar que el tráfico de red de Lustre utiliza EFA, utilice la `lnetctl` herramienta Lustre, que puede mostrar el tráfico de red de una interfaz de red determinada. Para ello, ejecute los siguientes comandos en un nodo de cómputo:

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

Si la función funciona, se espera que aumente la cantidad de paquetes que fluyen a través de la interfaz.