

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

# 注册可扩展目标
<a name="AutoScaling-Scaling-Registering-Policy-CLI"></a>

在将 Auto Scaling 与 for ElastiCache Valkey 和 Redis OSS 集群一起使用之前，您需要先注册集群进行 ElastiCache 自动扩展。您这样做是为了定义要应用于该集群的缩放维度和限制。 ElastiCache auto scaling 沿着`elasticache:replication-group:NodeGroups`可扩展维度（表示集群分片的数量）动态扩展集群。

 **使用 AWS CLI** 

要注册你的 ElastiCache Valkey 和 Redis OSS 集群，请使用带有以下参数的 re [gister-scalable](https://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/register-scalable-target.html)-target 命令：
+ `--service-namespace` – 将该值设置为 `elasticache`
+ `--resource-id` – 集群的资源标识符。对于该参数，资源类型为 `ReplicationGroup`，唯一标识符为集群的名称，例如 `replication-group/myscalablecluster`。
+ `--scalable-dimension` – 将该值设置为 `elasticache:replication-group:NodeGroups`。
+ `--max-capacity `— a ElastiCache uto scaling 要管理的最大分片数。有关 `--min-capacity`、`--max-capacity` 和集群中分区数之间关系的信息，请参阅 [最小和最大容量](AutoScaling-Policies.md#AutoScaling-MinMax)。
+ `--min-capacity `— a ElastiCache uto scaling 要管理的最小分片数。有关 `--min-capacity`、`--max-capacity` 和集群中分区数之间关系的信息，请参阅 [最小和最大容量](AutoScaling-Policies.md#AutoScaling-MinMax)。

**Example**  
 在以下示例中，您注册了一个名为的 ElastiCache 集群`myscalablecluster`。该注册表示应将集群动态扩展为具有 1 到 10 个分区。  
对于 Linux、macOS 或 Unix：  

```
aws application-autoscaling register-scalable-target \
    --service-namespace elasticache \
    --resource-id replication-group/myscalablecluster \
    --scalable-dimension elasticache:replication-group:NodeGroups \
    --min-capacity 1 \
    --max-capacity 10 \
```
对于 Windows：  

```
aws application-autoscaling register-scalable-target ^
    --service-namespace elasticache ^
    --resource-id replication-group/myscalablecluster ^
    --scalable-dimension elasticache:replication-group:NodeGroups ^
    --min-capacity 1 ^
    --max-capacity 10 ^
```

**使用 API**

要注册您的 ElastiCache 集群，请使用带有以下参数的 [register-scalable-target](https://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/register-scalable-target.html) 命令：
+ ServiceNamespace — 将此值设置为 elasticache。
+ 资源 ID-群集的资源标识符。 ElastiCache 例如，对于此参数，资源类型为 ReplicationGroup ，唯一标识符是群集的名称`replication-group/myscalablecluster`。
+ ScalableDimension — 将此值设置为`elasticache:replication-group:NodeGroups`。
+ MinCapacity — a ElastiCache uto scaling 要管理的最小分片数。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息，请参阅 [最小和最大容量](AutoScaling-Policies.md#AutoScaling-MinMax)。
+ MaxCapacity — a ElastiCache uto scaling 要管理的最大分片数。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息，请参阅 [最小和最大容量](AutoScaling-Policies.md#AutoScaling-MinMax)。

**Example**  
在以下示例中，您将使用 Application Auto Scaling API 注册一个名为`myscalablecluster`的 ElastiCache 集群。该注册表示应将集群动态扩展为具有 1 到 5 个副本。  

```
POST / HTTP/1.1
Host: autoscaling.us-east-2.amazonaws.com
Accept-Encoding: identity
Content-Length: 219
X-Amz-Target: AnyScaleFrontendService.RegisterScalableTarget
X-Amz-Date: 20160506T182145Z
User-Agent: aws-cli/1.10.23 Python/2.7.11 Darwin/15.4.0 botocore/1.4.8
Content-Type: application/x-amz-json-1.1
Authorization: AUTHPARAMS
{
    "ServiceNamespace": "elasticache",
    "ResourceId": "replication-group/myscalablecluster",
    "ScalableDimension": "elasticache:replication-group:NodeGroups",
    "MinCapacity": 1,
    "MaxCapacity": 5
}
```