应用扩缩策略 - Amazon ElastiCache
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

应用扩缩策略

在 Valkey 和 Redis a OSS uto Scaling 中注册集群并定义扩展策略后,您可以将扩展策略应用于已注册的集群。 ElastiCache 要将扩展策略应用于 Redis ElastiCache 的OSS集群,您可以使用 Amazon CLI 或 Application Auto Scaling API。

使用应用扩展策略 Amazon CLI

要将扩展策略应用 ElastiCache 于 Valkey 和 Redis OSS 集群,请使用带有以下参数的put-scaling-policy命令:

  • --policy-name – 扩展策略的名称。

  • --policy-type – 将此值设置为 TargetTrackingScaling

  • --resource-id – 资源标识符。对于该参数,资源类型为 ReplicationGroup,唯一标识符为集群的名称,例如 replication-group/myscalablecluster

  • --service-namespace – 将此值设置为 elasticache

  • --scalable-dimension – 将此值设置为 elasticache:replication-group:NodeGroups

  • --target-tracking-scaling-policy-conf iguration — 用于集群的目标跟踪扩展策略配置。

在以下示例中,您将名为的目标跟踪扩展策略应用于名为 auto scaling 的 myscalablepolicy fo ElastiCache r Valkey 和 Redis OSS 集群。myscalablecluster ElastiCache 为此,请使用在名为 config.json 的文件中保存的策略配置。

对于 Linux、macOS 或 Unix:

aws application-autoscaling put-scaling-policy \ --policy-name myscalablepolicy \ --policy-type TargetTrackingScaling \ --resource-id replication-group/myscalablecluster \ --service-namespace elasticache \ --scalable-dimension elasticache:replication-group:NodeGroups \ --target-tracking-scaling-policy-configuration file://config.json

对于 Windows:

aws application-autoscaling put-scaling-policy ^ --policy-name myscalablepolicy ^ --policy-type TargetTrackingScaling ^ --resource-id replication-group/myscalablecluster ^ --service-namespace elasticache ^ --scalable-dimension elasticache:replication-group:NodeGroups ^ --target-tracking-scaling-policy-configuration file://config.json

使用 API 应用扩展策略

要将扩展策略应用 ElastiCache 于 Valkey 和 Redis OSS 集群,请使用带有以下参数的PutScalingPolicy Amazon CLI 命令:

  • --policy-name – 扩展策略的名称。

  • --resource-id – 资源标识符。对于该参数,资源类型为 ReplicationGroup,唯一标识符为集群的名称,例如 replication-group/myscalablecluster

  • --service-namespace – 将此值设置为 elasticache

  • --scalable-dimension – 将此值设置为 elasticache:replication-group:NodeGroups

  • --target-tracking-scaling-policy-conf iguration — 用于集群的目标跟踪扩展策略配置。

在以下示例中,您将名为的目标跟踪扩展策略应用于名为 myscalablepolicy a myscalablecluster ElastiCache uto scaling 的 ElastiCache 集群。您使用的策略配置基于 ElastiCachePrimaryEngineCPUUtilization 预定义指标。

POST / HTTP/1.1 Host: autoscaling.us-east-2.amazonaws.com Accept-Encoding: identity Content-Length: 219 X-Amz-Target: AnyScaleFrontendService.PutScalingPolicy 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 { "PolicyName": "myscalablepolicy", "ServiceNamespace": "elasticache", "ResourceId": "replication-group/myscalablecluster", "ScalableDimension": "elasticache:replication-group:NodeGroups", "PolicyType": "TargetTrackingScaling", "TargetTrackingScalingPolicyConfiguration": { "TargetValue": 40.0, "PredefinedMetricSpecification": { "PredefinedMetricType": "ElastiCachePrimaryEngineCPUUtilization" } } }