本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
註冊可擴展的目標
您可以根據預先定義的指標或自訂指標,套用規模調整政策。若要這樣做,您可以使用 AWS CLI 或 Application Auto Scaling API。第一步是向 Auto Scaling 註冊 ElastiCache for Valkey 和 Redis OSS 複寫群組。
您必須先向 ElastiCache 自動擴展註冊叢集,才能搭配叢集使用 ElastiCache 自動擴展。這是為了定義要套用到叢集的擴展維度和限制。ElastiCache 自動擴展會沿著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 – ElastiCache 自動擴展管理的複本數量下限。如需了解 --min-capacity、--max-capacity 以及叢集中複本數之間的關係,請參閱「容量下限和上限」。
-
--max-capacity – 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。
ResourceID - ElastiCache 叢集的資源識別碼。在此參數中,資源類型為 ReplicationGroup,唯一識別符為叢集的名稱,例如
replication-group/myscalablecluster
。ScalableDimension - 將此值設為
elasticache:replication-group:Replicas
。MinCapacity – ElastiCache 自動擴展管理的複本數量下限。如需了解 --min-capacity、--max-capacity 以及叢集中複本數之間的關係,請參閱「容量下限和上限」。
MaxCapacity:由 ElastiCache 自動擴展管理的複本數量上限。如需了解 --min-capacity、--max-capacity 以及叢集中複本數之間的關係,請參閱「容量下限和上限」。
在下列範例中,您會myscalablecluster
使用 Application Auto Scaling 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 }