全部產品
Search
文件中心

Auto Scaling:EnableScalingGroup

更新時間:Jan 14, 2025

如果伸縮組處於停用狀態,並且該伸縮組已通過指定啟動模板方式或者建立並啟用伸縮配置方式指定了執行個體配置來源,您可以調用API EnableScalingGroup啟用一個伸縮組,通過Auto Scaling來自動調整您的業務計算能力(即執行個體數量)。

介面說明

  • 當伸縮組處於Inactive狀態,且伸縮組配置了組內執行個體的配置資訊來源(伸縮配置、啟動模板或者在建立伸縮組時指定ECS執行個體)時,才可以調用該介面來啟用伸縮組。否則,會調用失敗。

    說明 一個伸縮組在同一時刻有且只有一個生效的執行個體配置資訊來源。在調用介面時,您可以為伸縮組指定伸縮配置或啟動模板。如果調用該介面前您已經為伸縮組配置了執行個體配置資訊來源,在調用時再指定伸縮配置或啟動模板會覆蓋原有的配置資訊。

  • 當該介面指定了加入伸縮組的ECS執行個體(InstanceId.N),調用該介面後,Auto Scaling會判斷在加入ECS執行個體後伸縮組的ECS執行個體數量(Total Capacity)是否在最小值(MinSize)和最大值(MaxSize)之間:
    • 如果伸縮組的Total Capacity小於MinSize,調用成功後,Auto Scaling服務會自動建立差額的隨用隨付的ECS執行個體。

      例如:建立伸縮組時,指定MinSize為5,在啟用伸縮組的InstanceId.N參數中指定2台已有ECS執行個體,則Auto Scaling在加入2台已有ECS執行個體之後,再自動建立3台ECS執行個體。

    • 如果伸縮組的Total Capacity大於MaxSize,則調用失敗。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

請求參數

名稱

類型

是否必選

樣本值

描述

Action String EnableScalingGroup

系統規定參數。取值:EnableScalingGroup

ScalingGroupId String asg-bp14wlu85wrpchm0****

伸縮組的ID。

ActiveScalingConfigurationId String asc-bp1ffogfdauy0nu5****

需要在伸縮組內啟用的伸縮配置的ID。

LaunchTemplateId String lt-m5e3ofjr1zn1aw7****

執行個體啟動模板的ID,用於指定伸縮組從執行個體啟動模板擷取啟動配置資訊。

LaunchTemplateVersion String Default

執行個體啟動模板的版本。取值範圍:

  • 固定的模板版本號碼。
  • Default:始終使用模板預設版本。
  • Latest:始終使用模板最新版本。
InstanceId.N String i-283vv****

啟用伸縮組後需要加入伸縮組的ECS執行個體的ID,N的取值範圍:1~20。

指定加入伸縮組的ECS執行個體需要滿足以下條件:

  • 必須與伸縮組在同一個地區。
  • 必須處於Running狀態。
  • 不能已加入到其他伸縮組中。
  • 付費方式為訂用帳戶、隨用隨付或搶佔式執行個體。
  • 如果伸縮組指定VswitchID,則不支援Classic類型的ECS執行個體加入伸縮組,也不支援其他VPC的ECS執行個體加入伸縮組。
  • 如果伸縮組沒有指定VswitchID,則不支援VPC類型的ECS執行個體加入伸縮組。
LoadBalancerWeight.N Integer 50

加入伸縮組的ECS執行個體或ECI執行個體作為後端伺服器的權重,N的取值範圍:1~20,該參數取值範圍:1~100。

預設值:50。

LaunchTemplateOverride.N.InstanceType String ecs.c5.xlarge

當您需要伸縮組按照執行個體規格容量進行伸縮時,請同時指定本參數和LaunchTemplateOverride.N.WeightedCapacity。

本參數用於指定執行個體規格,會覆蓋啟動模板中的執行個體規格。您可以指定N個本參數,擴充啟動模板支援N個執行個體規格。N的取值範圍:1~10。

說明 僅當LaunchTemplateId參數指定了啟動模板時,本參數生效。

InstanceType的取值範圍:在售的ECS執行個體規格,請參見執行個體規格類型系列

LaunchTemplateOverride.N.WeightedCapacity Integer 4

當您需要伸縮組按照執行個體規格容量進行伸縮時,在指定LaunchTemplateOverride.N.InstanceType後,再指定本參數。兩個參數一一對應,N需要保持一致。

本參數用於指定執行個體規格的權重,即執行個體規格的單台執行個體在伸縮組中表示的容量大小。權重越大,滿足期望容量所需的本執行個體規格的執行個體數量越少。

由於每個執行個體規格的vCPU個數、記憶體大小等效能指標會有差異,您可以根據自身需求,給不同的執行個體規格配置不同的權重。

例如:

  • 當前容量:0。
  • 期望容量:6。
  • ecs.c5.xlarge規格容量:4。

為滿足期望容量,伸縮組將為使用者擴容2台ecs.c5.xlarge執行個體。

說明 擴容時伸縮組的容量不得超過最大容量(MaxSize)與執行個體規格的最大權重之和。

WeightedCapacity的取值範圍:1~500。

RegionId String cn-qingdao

伸縮組所屬的地區ID。

返回資料

名稱

類型

樣本值

描述

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

請求ID。

樣本

請求樣本

http(s)://ess.aliyuncs.com/?Action=EnableScalingGroup
&ScalingGroupId=asg-bp14wlu85wrpchm0****
&ActiveScalingConfigurationId=asc-bp1ffogfdauy0nu5****
&LaunchTemplateId=lt-m5e3ofjr1zn1aw7****
&LaunchTemplateVersion=Default
&InstanceId=["i-283vv****"]
&LoadBalancerWeight=[50]
&LaunchTemplateOverride=[{"InstanceType":"ecs.c5.xlarge","WeightedCapacity":4}]
&RegionId=cn-qingdao
&公用請求參數

正常返回樣本

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<EnableScalingGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</EnableScalingGroupResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。

HttpCode

錯誤碼

錯誤資訊

描述

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

指定的伸縮組在當前帳號下不存在。

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

您並未向Auto Scaling完整授權OpenAPI介面。

400

IncorrectScalingGroupStatus

The current status of the specified scaling group does not support this action.

指定的伸縮組處於Deleting狀態。

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

指定的伸縮配置不存在指定的伸縮組中。

400

InvalidScalingConfigurationId.InstanceTypeMismatch

The specified scaling configuration and existing active scaling configuration have different instance type.

指定的伸縮配置的執行個體規格與當前生效的伸縮配置的執行個體規格不匹配。

400

MissingActiveScalingConfiguration

An active scaling configuration for the specified scaling group is not supplied.

伸縮組中未指定生效的伸縮配置。

404

InvalidInstanceId.NotFound

Instance "XXX" does not exist.

指定的ECS執行個體在當前帳號下不存在。

400

InvalidInstanceId. RegionMismatch

Instance "XXX" and the specified scaling group are not in the same Region.

指定的ECS執行個體與伸縮組所處的地區不匹配。

400

InvalidInstanceId. InstanceTypeMismatch

Instance "XXX" and existing active scaling configuration have different instance type.

指定的ECS執行個體與伸縮配置的執行個體規格不匹配。

400

IncorrectInstanceStatus

The current status of instance "XXX" does not support this action.

指定的ECS執行個體未處於Running狀態。

400

InvalidInstanceId. NetworkTypeMismatch

The network type of instance "XXX" does not support this action.

指定的ECS執行個體的網路類型與伸縮組的網路類型不符。

400

InvalidInstanceId.VPCMismatch

Instance "XXX" and the specified scaling group are not in the same VPC.

指定的伸縮組與添加的ECS執行個體不在同一個VPC當中。

400

InvalidInstanceId.InUse

Instance "XXX" is already attached to another scaling group.

指定的ECS執行個體已加入其它伸縮組。

400

IncorrectLoadBalancerStatus

The current status of the specified load balancer does not support this action.

指定的Server Load Balancer執行個體未處於active狀態。

400

IncorrectLoadBalancerHealthCheck

The current health check type of specified load balancer does not support this action.

指定的Server Load Balancer執行個體未開啟健全狀態檢查。

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

The network type of the instance in specified Load Balancer does not support this action.

指定的Server Load Balancer執行個體含有的ECS執行個體的網路類型與伸縮組的網路類型不符。

400

InvalidLoadBalancerId.VPCMismatch

The specified virtual switch and the instance in specified Load Balancer are not in the same VPC.

指定的伸縮組的Server Load Balancer執行個體含有的ECS執行個體與VSwitchId不在同一個VPC當中。

400

IncorrectDBInstanceStatus

The current status of DB instance "XXX" does not support this action.

指定的RDS執行個體未處於Running狀態。

400

IncorrectCapacity.MaxSize

To attach the instances, the total capacity will be greater than the max size.

加入的ECS執行個體數使得Total Capacity超過MaxSize。

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

執行個體啟動模板指定版本不存在。

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

指定執行個體啟動模板不存在。

400

TemplateMissingParameter.ImageId

The input parameter "ImageId" that is mandatory for processing this request is not supplied.

執行個體啟動模板指定版本缺少鏡像資訊。

400

TemplateMissingParameter.InstanceTypes

The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied.

執行個體啟動模板指定版本缺少執行個體規格資訊。

400

TemplateMissingParameter.SecurityGroup

The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied.

執行個體啟動模板指定版本缺少安全性群組資訊。

400

TemplateVersion.NotNumber

The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number.

指定執行個體啟動模板固定版本號碼為非數字。