

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

下列範例組態示範使用 Slurm、 Torque和 AWS Batch 排程器的 AWS ParallelCluster 組態。

**注意**  
從 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` Spot 執行個體可用。它最多可擴展至 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 分鐘內沒有任務執行時縮減至兩個節點。

```
[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 服務和 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
```