本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
注册可扩展目标
您需要先对 ElastiCache for Redis 集群注册 ElastiCache for Redis 弹性伸缩,才能对集群使用弹性伸缩。这样做是为了定义应用于该集群的扩展维度和限制。ElastiCache for Redis 弹性伸缩会连同 elasticache:replication-group:NodeGroups
可扩展维度一起动态扩展 ElastiCache for Redis 集群,该可扩展维度表示集群分区的数量。
使用 Amazon CLI
要注册 ElastiCache for Redis 集群,请使用包含下列参数的 register-scalable-target 命令:
-
--service-namespace
– 将该值设置为elasticache
-
--resource-id
– ElastiCache for Redis 集群的资源标识符。对于此参数,资源类型为ReplicationGroup
,唯一标识符为 ElastiCache for Redis 集群的名称,例如replication-group/myscalablecluster
。 -
--scalable-dimension
– 将该值设置为elasticache:replication-group:NodeGroups
。 -
--max-capacity
– 由 ElastiCache for Redis 弹性伸缩管理的最大分区数。有关--min-capacity
、--max-capacity
和集群中分区数之间关系的信息,请参阅 最小和最大容量。 -
--min-capacity
– 由 ElastiCache for Redis 弹性伸缩管理的最小分区数。有关--min-capacity
、--max-capacity
和集群中分区数之间关系的信息,请参阅 最小和最大容量。
在以下示例中,您注册一个名为 myscalablecluster
的 ElastiCache for Redis 集群。该注册表示应将集群动态扩展为具有 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 命令:
ServiceNamespace – 将此值设置为 elasticache。
ResourceID – ElastiCache 集群的资源标识符。对于此参数,资源类型为复制组,唯一标识符为 ElastiCache for Redis 集群的名称,例如
replication-group/myscalablecluster
。ScalableDimension – 将此值设置为
elasticache:replication-group:NodeGroups
。MinCapacity – 由 ElastiCache for Redis 弹性伸缩管理的最小分区数。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
MaxCapacity – 由 ElastiCache for Redis 弹性伸缩管理的最大分区数。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
在以下示例中,您使用 Application Auto Scaling API 注册一个名为 myscalablecluster
的 ElastiCache for Redis 集群。该注册表示应将集群动态扩展为具有 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 }