

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

# 示例
<a name="examples"></a>

以下示例配置演示了使用以下方法的 AWS ParallelCluster 配置 Slurm, Torque和 AWS Batch 调度程序。

**注意**  
从 2.11.5 版开始， AWS ParallelCluster 不支持使用 SGE 或 Torque 调度器。

**Contents**
+ [Slurm Workload Manager (`slurm`)](#example.slurm)
+ [Son of Grid Engine (`sge`) 和 Torque Resource Manager (`torque`)](#example.torque)
+ [AWS Batch (`awsbatch`)](#example.awsbatch)

## Slurm Workload Manager (`slurm`)
<a name="example.slurm"></a>

以下示例使用 `slurm` 计划程序启动集群。该示例配置启动 1 个包含 2 个作业队列的集群。第一个队列 `spot` 最初具有 2 个可用的 `t3.micro` 竞价型实例。它可以纵向扩展到最多 10 个实例，并可在 10 分钟没有作业运行时缩减到最少 1 个实例（可使用 [`scaledown_idletime`](scaling-section.md#scaledown-idletime) 设置进行调整）。第二个队列 `ondemand` 从没有实例开始，最多可以纵向扩展到 5 个 `t3.micro` 按需型实例。

```
[global]
update_check = true
sanity_check = true
cluster_template = slurm

[aws]
aws_region_name = <your AWS 区域>

[vpc public]
master_subnet_id = <your subnet>
vpc_id = <your VPC>

[cluster slurm]
key_name = <your EC2 keypair name>
base_os = alinux2                   # optional, defaults to alinux2
scheduler = slurm
master_instance_type = t3.micro     # optional, defaults to t3.micro
vpc_settings = public
queue_settings = spot,ondemand

[queue spot]
compute_resource_settings = spot_i1
compute_type = spot                 # optional, defaults to ondemand

[compute_resource spot_i1]
instance_type = t3.micro
min_count = 1                       # optional, defaults to 0
initial_count = 2                   # optional, defaults to 0

[queue ondemand]
compute_resource_settings = ondemand_i1

[compute_resource ondemand_i1]
instance_type = t3.micro
max_count = 5                       # optional, defaults to 10
```

## Son of Grid Engine (`sge`) 和 Torque Resource Manager (`torque`)
<a name="example.torque"></a>

**注意**  
此示例仅适用于 AWS ParallelCluster 2.11.4 及以下版本。从 2.11.5 版开始， AWS ParallelCluster 不支持使用 SGE 或 Torque 调度器。

以下示例使用 `torque` 划 `sge` 调度器启动集群。要将 SGE，更改`scheduler = torque`为`scheduler = sge`。该示例配置允许最多 5 个并发节点，且当 10 分钟没有作业运行时缩减到 2 个节点。

```
[global]
update_check = true
sanity_check = true
cluster_template = torque

[aws]
aws_region_name = <your AWS 区域>

[vpc public]
master_subnet_id = <your subnet>
vpc_id = <your VPC>

[cluster torque]
key_name = <your EC2 keypair name>but they aren't eligible for future updates
base_os = alinux2                   # optional, defaults to alinux2
scheduler = torque                  # optional, defaults to sge
master_instance_type = t3.micro     # optional, defaults to t3.micro
vpc_settings = public
initial_queue_size = 2              # optional, defaults to 0
maintain_initial_size = true        # optional, defaults to false
max_queue_size = 5                  # optional, defaults to 10
```

**注意**  
从 2.11.5 版开始， AWS ParallelCluster 不支持使用 SGE 或 Torque 调度器。如果您使用这些版本，则可以继续使用它们，或者从 AWS 服务和 Support 团队那里获得故障排除 AWS 支持。

## AWS Batch (`awsbatch`)
<a name="example.awsbatch"></a>

以下示例使用 `awsbatch` 计划程序启动集群。它设置为根据您的作业资源需求来选择更好的实例类型。

该示例配置允许最多 40 个并发 vCPUs，并且在 10 分钟内没有作业运行时缩小到零（可使用该[`scaledown_idletime`](scaling-section.md#scaledown-idletime)设置进行调整）。

```
[global]
update_check = true
sanity_check = true
cluster_template = awsbatch

[aws]
aws_region_name = <your AWS 区域>

[vpc public]
master_subnet_id = <your subnet>
vpc_id = <your VPC>

[cluster awsbatch]
scheduler = awsbatch
compute_instance_type = optimal # optional, defaults to optimal
min_vcpus = 0                   # optional, defaults to 0
desired_vcpus = 0               # optional, defaults to 4
max_vcpus = 40                  # optional, defaults to 20
base_os = alinux2               # optional, defaults to alinux2, controls the base_os of
                                # the head node and the docker image for the compute fleet
key_name = <your EC2 keypair name>
vpc_settings = public
```