本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
注册可扩展目标
您可以应用基于预定义或自定义指标的扩展策略。为此,您可以使用 Amazon CLI 或 Application Auto Scaling API。第一步是在 Auto Scaling 中注册你 ElastiCache 的 Valkey 和 Redis OSS 复制组。
在对集群使用 ElastiCache 自动伸缩功能之前,必须先注册集群,然后才能使用 ElastiCache 自动扩展。您这样做是为了定义要应用于该集群的缩放维度和限制。 ElastiCache auto scaling 沿着elasticache:replication-group:Replicas
可扩展维度动态扩展集群,该维度表示每个分片的集群副本数。
使用 CLI
要注册您的 ElastiCache 集群,请使用带有以下参数的register-scalable-target命令:
-
--service-namespace – 将此值设置为 elasticache。
-
--resource-id — 集群的资源标识符。 ElastiCache 例如,对于此参数,资源类型为 ReplicationGroup ,唯一标识符是群集的名称
replication-group/myscalablecluster
。 -
--scalable-dimension – 将此值设置为
elasticache:replication-group:Replicas
。 -
--min-capacity — auto Scaling 要管理的最小副本数量。 ElastiCache 有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
-
--max-capacity — auto Scaling 要管理的最大副本数。 ElastiCache 有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
在以下示例中,您注册了一个名为的 ElastiCache 集群myscalablecluster
。该注册表示应将集群动态扩展为具有 1 到 5 个副本。
对于 Linux、macOS 或 Unix:
aws application-autoscaling register-scalable-target \ --service-namespace elasticache \ --resource-id replication-group/myscalablecluster \ --scalable-dimension elasticache:replication-group:Replicas \ --min-capacity 1 \ --max-capacity 5 \
对于 Windows:
aws application-autoscaling register-scalable-target ^ --service-namespace elasticache ^ --resource-id replication-group/myscalablecluster ^ --scalable-dimension elasticache:replication-group:Replicas ^ --min-capacity 1 ^ --max-capacity 5 ^
使用 API
要注册您的 ElastiCache 集群,请使用带有以下参数的register-scalable-target命令:
ServiceNamespace — 将此值设置为 elasticache。
资源 ID-群集的资源标识符。 ElastiCache 例如,对于此参数,资源类型为 ReplicationGroup ,唯一标识符是群集的名称
replication-group/myscalablecluster
。ScalableDimension — 将此值设置为
elasticache:replication-group:Replicas
。MinCapacity — a ElastiCache uto scaling 要管理的最小副本数量。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
MaxCapacity — a ElastiCache uto Scaling 要管理的最大副本数。有关 --min-capacity、--max-capacity 和集群中副本数之间关系的信息,请参阅 最小和最大容量。
在以下示例中,您将向 Application Auto Scaling 注册一个名为myscalablecluster
的集群API。该注册表示应将集群动态扩展为具有 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:Replicas", "MinCapacity": 1, "MaxCapacity": 5 }