管理 Application Auto Scaling 的计划扩展 - Application Auto Scaling
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

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

管理 Application Auto Scaling 的计划扩展

这些区域有:Amazon CLI包括其他几个可帮助您管理计划操作的命令。

查看指定服务的扩展活动

要查看指定服务命名空间中所有可扩展目标的扩展活动,请使用describe-scaling-activities命令。

下面的示例检索与dynamodb服务命名空间。

Linux、macOS 或 Unix

aws application-autoscaling describe-scaling-activities --service-namespace dynamodb

Windows

aws application-autoscaling describe-scaling-activities --service-namespace dynamodb

如果命令成功,则将显示类似于以下内容的输出。

{ "ScalingActivities": [ { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 10.", "ResourceId": "table/my-table", "ActivityId": "4d1308c0-bbcf-4514-a673-b0220ae38547", "StartTime": 1561574415.086, "ServiceNamespace": "dynamodb", "EndTime": 1561574449.51, "Cause": "maximum capacity was set to 10", "StatusMessage": "Successfully set write capacity units to 10. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 5 and max capacity to 10", "ResourceId": "table/my-table", "ActivityId": "f2b7847b-721d-4e01-8ef0-0c8d3bacc1c7", "StartTime": 1561574414.644, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-second-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 5 and max capacity to 10", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 15.", "ResourceId": "table/my-table", "ActivityId": "d8ea4de6-9eaa-499f-b466-2cc5e681ba8b", "StartTime": 1561574108.904, "ServiceNamespace": "dynamodb", "EndTime": 1561574140.255, "Cause": "minimum capacity was set to 15", "StatusMessage": "Successfully set write capacity units to 15. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 15 and max capacity to 20", "ResourceId": "table/my-table", "ActivityId": "3250fd06-6940-4e8e-bb1f-d494db7554d2", "StartTime": 1561574108.512, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-first-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 15 and max capacity to 20", "StatusCode": "Successful" } ] }

要更改此命令以便仅检索其中一个可扩展目标的扩展活动,请添加--resource-id选项。

描述指定服务的所有计划操作

要描述指定服务命名空间中所有可扩展目标的计划操作,请使用describe-scheduled-actions命令。

下面的示例检索与ec2服务命名空间。

Linux、macOS 或 Unix

aws application-autoscaling describe-scheduled-actions --service-namespace ec2

Windows

aws application-autoscaling describe-scheduled-actions --service-namespace ec2

如果成功,该命令返回类似以下内容的输出。

{ "ScheduledActions": [ { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2021-01-31T17:00:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MaxCapacity": 1 }, "CreationTime": 1607454792.331 }, { "ScheduledActionName": "my-recurring-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-recurring-action", "ServiceNamespace": "ec2", "Schedule": "rate(5 minutes)", "ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "StartTime": 1604059200.0, "EndTime": 1612130400.0, "ScalableTargetAction": { "MinCapacity": 3, "MaxCapacity": 10 }, "CreationTime": 1607454949.719 }, { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2020-12-08T9:36:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MinCapacity": 1, "MaxCapacity": 3 }, "CreationTime": 1607456031.391 } ] }

描述可扩展目标的一个或多个计划操作

要检索有关指定可扩展目标的计划操作的信息,请将--resource-id选项描述调度操作时使用describe-scheduled-actions命令。

如果您包含--scheduled-action-names选项并将调度操作的名称指定为其值,则该命令仅返回名称匹配的计划操作,如以下示例所示。

Linux、macOS 或 Unix

aws application-autoscaling describe-scheduled-actions --service-namespace ec2 \ --resource-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE \ --scheduled-action-names my-one-time-action

Windows

aws application-autoscaling describe-scheduled-actions --service-namespace ec2 --resource-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE --scheduled-action-names my-one-time-action

下面是示例输出。

{ "ScheduledActions": [ { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2020-12-08T9:36:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MinCapacity": 1, "MaxCapacity": 3 }, "CreationTime": 1607456031.391 } ] }

如果为--scheduled-action-names选项,则将包括名称匹配的所有计划操作。

关闭可扩展目标的计划扩展

您可以暂时关闭计划扩展而不删除您的计划操作。有关更多信息,请参阅 暂停和恢复 Application Auto Scaling 的扩展

暂停可扩展目标上的调度扩展,使用register-scalable-target命令,--suspended-state选项,然后指定true作为ScheduledScalingSuspended属性,如以下示例所示。

Linux、macOS 或 Unix

aws application-autoscaling register-scalable-target --service-namespace rds \ --scalable-dimension rds:cluster:ReadReplicaCount --resource-id cluster:my-db-cluster \ --suspended-state '{"ScheduledScalingSuspended": true}'

Windows

aws application-autoscaling register-scalable-target --service-namespace rds --scalable-dimension rds:cluster:ReadReplicaCount --resource-id cluster:my-db-cluster --suspended-state "{\"ScheduledScalingSuspended\": true}"

如果成功,该命令返回到提示符。

要恢复计划扩展,请再次运行此命令,指定false作为ScheduledScalingSuspended属性。

删除计划操作

在使用完计划的操作后,您可以使用 delete-scheduled-action 命令将其删除。

Linux、macOS 或 Unix

aws application-autoscaling delete-scheduled-action --service-namespace ec2 \ --scalable-dimension ec2:spot-fleet-request:TargetCapacity \ --resource-id spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-37294EXAMPLE \ --scheduled-action-name my-recurring-action

Windows

aws application-autoscaling delete-scheduled-action --service-namespace ec2 --scalable-dimension ec2:spot-fleet-request:TargetCapacity --resource-id spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-37294EXAMPLE --scheduled-action-name my-recurring-action

如果成功,该命令返回到提示符。