本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
註冊可擴展的目標
您必須先向 ElastiCache Auto Scaling註冊叢集,才能搭配 ElastiCache for Valkey 和 Redis OSS 叢集使用 Auto Scaling。這是為了定義要套用到叢集的擴展維度和限制。ElastiCache 自動擴展會沿著elasticache:replication-group:NodeGroups
可擴展維度動態擴展叢集,此維度代表叢集碎片的數量。
使用 AWS CLI
若要註冊 ElastiCache for Valkey 和 Redis OSS 叢集,請使用 register-scalable-target 命令搭配下列參數:
-
--service-namespace
– 將此值設定為elasticache
-
--resource-id
– 叢集的資源識別符。在此參數中,資源類型為ReplicationGroup
,唯一識別符為叢集的名稱,例如replication-group/myscalablecluster
。 -
--scalable-dimension
– 將此值設定為elasticache:replication-group:NodeGroups
。 -
--max-capacity
– ElastiCache 自動擴展管理的碎片數量上限。如需了解有關--min-capacity
、--max-capacity
以及叢集中碎片數目之間的關係資訊,請參閱「容量下限和上限」。 -
--min-capacity
– ElastiCache 自動擴展管理的碎片數量下限。如需了解有關--min-capacity
、--max-capacity
以及叢集中碎片數目之間的關係資訊,請參閱「容量下限和上限」。
在下列範例中,您會註冊名為 的 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 命令搭配下列參數:
ServiceNamespace - 將此值設為 elasticache。
ResourceID - ElastiCache 叢集的資源識別碼。在此參數中,資源類型為 ReplicationGroup,唯一識別符為叢集的名稱,例如
replication-group/myscalablecluster
。ScalableDimension - 將此值設為
elasticache:replication-group:NodeGroups
。MinCapacity – ElastiCache 自動擴展管理的碎片數量下限。如需了解 --min-capacity、--max-capacity 以及叢集中複本數之間的關係,請參閱「容量下限和上限」。
MaxCapacity – ElastiCache 自動擴展管理的碎片數量上限。如需了解 --min-capacity、--max-capacity 以及叢集中複本數之間的關係,請參閱「容量下限和上限」。
在下列範例中,您會myscalablecluster
使用 Application Auto Scaling API 註冊名為 的 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 }