EnableScalingGroup
如果伸縮組處于停用狀態(tài),并且該伸縮組已通過指定啟動(dòng)模板方式或者創(chuàng)建并啟用伸縮配置方式指定了實(shí)例配置來(lái)源,您可以調(diào)用API EnableScalingGroup啟用一個(gè)伸縮組,通過彈性伸縮來(lái)自動(dòng)調(diào)整您的業(yè)務(wù)計(jì)算能力(即實(shí)例數(shù)量)。
接口說明
-
當(dāng)伸縮組處于Inactive狀態(tài),且伸縮組配置了組內(nèi)實(shí)例的配置信息來(lái)源(伸縮配置、啟動(dòng)模板或者在創(chuàng)建伸縮組時(shí)指定ECS實(shí)例)時(shí),才可以調(diào)用該接口來(lái)啟用伸縮組。否則,會(huì)調(diào)用失敗。
說明 一個(gè)伸縮組在同一時(shí)刻有且只有一個(gè)生效的實(shí)例配置信息來(lái)源。在調(diào)用接口時(shí),您可以為伸縮組指定伸縮配置或啟動(dòng)模板。如果調(diào)用該接口前您已經(jīng)為伸縮組配置了實(shí)例配置信息來(lái)源,在調(diào)用時(shí)再指定伸縮配置或啟動(dòng)模板會(huì)覆蓋原有的配置信息。 - 當(dāng)該接口指定了加入伸縮組的ECS實(shí)例(InstanceId.N),調(diào)用該接口后,彈性伸縮會(huì)判斷在加入ECS實(shí)例后伸縮組的ECS實(shí)例數(shù)量(Total Capacity)是否在最小值(MinSize)和最大值(MaxSize)之間:
-
如果伸縮組的Total Capacity小于MinSize,調(diào)用成功后,彈性伸縮服務(wù)會(huì)自動(dòng)創(chuàng)建差額的按量付費(fèi)的ECS實(shí)例。
例如:創(chuàng)建伸縮組時(shí),指定MinSize為5,在啟用伸縮組的InstanceId.N參數(shù)中指定2臺(tái)已有ECS實(shí)例,則彈性伸縮在加入2臺(tái)已有ECS實(shí)例之后,再自動(dòng)創(chuàng)建3臺(tái)ECS實(shí)例。
- 如果伸縮組的Total Capacity大于MaxSize,則調(diào)用失敗。
-
調(diào)試
您可以在OpenAPI Explorer中直接運(yùn)行該接口,免去您計(jì)算簽名的困擾。運(yùn)行成功后,OpenAPI Explorer可以自動(dòng)生成SDK代碼示例。
請(qǐng)求參數(shù)
名稱 |
類型 |
是否必選 |
示例值 |
描述 |
Action | String | 是 | EnableScalingGroup | 系統(tǒng)規(guī)定參數(shù)。取值:EnableScalingGroup。 |
ScalingGroupId | String | 是 | asg-bp14wlu85wrpchm0**** | 伸縮組的ID。 |
ActiveScalingConfigurationId | String | 否 | asc-bp1ffogfdauy0nu5**** | 需要在伸縮組內(nèi)啟用的伸縮配置的ID。 |
LaunchTemplateId | String | 否 | lt-m5e3ofjr1zn1aw7**** | 實(shí)例啟動(dòng)模板的ID,用于指定伸縮組從實(shí)例啟動(dòng)模板獲取啟動(dòng)配置信息。 |
LaunchTemplateVersion | String | 否 | Default | 實(shí)例啟動(dòng)模板的版本。取值范圍:
|
InstanceId.N | String | 否 | i-283vv**** | 啟用伸縮組后需要加入伸縮組的ECS實(shí)例的ID,N的取值范圍:1~20。 指定加入伸縮組的ECS實(shí)例需要滿足以下條件:
|
LoadBalancerWeight.N | Integer | 否 | 50 | 加入伸縮組的ECS實(shí)例或ECI實(shí)例作為后端服務(wù)器的權(quán)重,N的取值范圍:1~20,該參數(shù)取值范圍:1~100。 默認(rèn)值:50。 |
LaunchTemplateOverride.N.InstanceType | String | 否 | ecs.c5.xlarge | 當(dāng)您需要伸縮組按照實(shí)例規(guī)格容量進(jìn)行伸縮時(shí),請(qǐng)同時(shí)指定本參數(shù)和LaunchTemplateOverride.N.WeightedCapacity。 本參數(shù)用于指定實(shí)例規(guī)格,會(huì)覆蓋啟動(dòng)模板中的實(shí)例規(guī)格。您可以指定N個(gè)本參數(shù),擴(kuò)展啟動(dòng)模板支持N個(gè)實(shí)例規(guī)格。N的取值范圍:1~10。 說明 僅當(dāng)LaunchTemplateId參數(shù)指定了啟動(dòng)模板時(shí),本參數(shù)生效。 InstanceType的取值范圍:在售的ECS實(shí)例規(guī)格,請(qǐng)參見實(shí)例規(guī)格族。 |
LaunchTemplateOverride.N.WeightedCapacity | Integer | 否 | 4 | 當(dāng)您需要伸縮組按照實(shí)例規(guī)格容量進(jìn)行伸縮時(shí),在指定LaunchTemplateOverride.N.InstanceType后,再指定本參數(shù)。兩個(gè)參數(shù)一一對(duì)應(yīng),N需要保持一致。 本參數(shù)用于指定實(shí)例規(guī)格的權(quán)重,即實(shí)例規(guī)格的單臺(tái)實(shí)例在伸縮組中表示的容量大小。權(quán)重越大,滿足期望容量所需的本實(shí)例規(guī)格的實(shí)例數(shù)量越少。 由于每個(gè)實(shí)例規(guī)格的vCPU個(gè)數(shù)、內(nèi)存大小等性能指標(biāo)會(huì)有差異,您可以根據(jù)自身需求,給不同的實(shí)例規(guī)格配置不同的權(quán)重。 例如:
為滿足期望容量,伸縮組將為用戶擴(kuò)容2臺(tái)ecs.c5.xlarge實(shí)例。 說明 擴(kuò)容時(shí)伸縮組的容量不得超過最大容量(MaxSize)與實(shí)例規(guī)格的最大權(quán)重之和。 WeightedCapacity的取值范圍:1~500。 |
RegionId | String | 否 | cn-qingdao | 伸縮組所屬的地域ID。 |
返回?cái)?shù)據(jù)
名稱 |
類型 |
示例值 |
描述 |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** | 請(qǐng)求ID。 |
示例
請(qǐng)求示例
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
&公共請(qǐng)求參數(shù)
正常返回示例
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****"
}
錯(cuò)誤碼
訪問錯(cuò)誤中心查看更多錯(cuò)誤碼。
HttpCode |
錯(cuò)誤碼 |
錯(cuò)誤信息 |
描述 |
404 |
InvalidScalingGroupId.NotFound |
The specified scaling group does not exist. |
指定的伸縮組在當(dāng)前賬號(hào)下不存在。 |
403 |
Forbidden.Unauthorized |
A required authorization for the specified action is not supplied. |
您并未向彈性伸縮完整授權(quán)OpenAPI接口。 |
400 |
IncorrectScalingGroupStatus |
The current status of the specified scaling group does not support this action. |
指定的伸縮組處于Deleting狀態(tài)。 |
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. |
指定的伸縮配置的實(shí)例規(guī)格與當(dāng)前生效的伸縮配置的實(shí)例規(guī)格不匹配。 |
400 |
MissingActiveScalingConfiguration |
An active scaling configuration for the specified scaling group is not supplied. |
伸縮組中未指定生效的伸縮配置。 |
404 |
InvalidInstanceId.NotFound |
Instance "XXX" does not exist. |
指定的ECS實(shí)例在當(dāng)前賬號(hào)下不存在。 |
400 |
InvalidInstanceId. RegionMismatch |
Instance "XXX" and the specified scaling group are not in the same Region. |
指定的ECS實(shí)例與伸縮組所處的地域不匹配。 |
400 |
InvalidInstanceId. InstanceTypeMismatch |
Instance "XXX" and existing active scaling configuration have different instance type. |
指定的ECS實(shí)例與伸縮配置的實(shí)例規(guī)格不匹配。 |
400 |
IncorrectInstanceStatus |
The current status of instance "XXX" does not support this action. |
指定的ECS實(shí)例未處于Running狀態(tài)。 |
400 |
InvalidInstanceId. NetworkTypeMismatch |
The network type of instance "XXX" does not support this action. |
指定的ECS實(shí)例的網(wǎng)絡(luò)類型與伸縮組的網(wǎng)絡(luò)類型不匹配。 |
400 |
InvalidInstanceId.VPCMismatch |
Instance "XXX" and the specified scaling group are not in the same VPC. |
指定的伸縮組與添加的ECS實(shí)例不在同一個(gè)VPC當(dāng)中。 |
400 |
InvalidInstanceId.InUse |
Instance "XXX" is already attached to another scaling group. |
指定的ECS實(shí)例已加入其它伸縮組。 |
400 |
IncorrectLoadBalancerStatus |
The current status of the specified load balancer does not support this action. |
指定的負(fù)載均衡實(shí)例未處于active狀態(tài)。 |
400 |
IncorrectLoadBalancerHealthCheck |
The current health check type of specified load balancer does not support this action. |
指定的負(fù)載均衡實(shí)例未開啟健康檢查。 |
400 |
InvalidLoadBalancerId.IncorrectInstanceNetworkType |
The network type of the instance in specified Load Balancer does not support this action. |
指定的負(fù)載均衡實(shí)例含有的ECS實(shí)例的網(wǎng)絡(luò)類型與伸縮組的網(wǎng)絡(luò)類型不匹配。 |
400 |
InvalidLoadBalancerId.VPCMismatch |
The specified virtual switch and the instance in specified Load Balancer are not in the same VPC. |
指定的伸縮組的負(fù)載均衡實(shí)例含有的ECS實(shí)例與VSwitchId不在同一個(gè)VPC當(dāng)中。 |
400 |
IncorrectDBInstanceStatus |
The current status of DB instance "XXX" does not support this action. |
指定的RDS實(shí)例未處于Running狀態(tài)。 |
400 |
IncorrectCapacity.MaxSize |
To attach the instances, the total capacity will be greater than the max size. |
加入的ECS實(shí)例數(shù)使得Total Capacity超過MaxSize。 |
400 |
LaunchTemplateVersionSet.NotFound |
The specific version of launch template is not exist. |
實(shí)例啟動(dòng)模板指定版本不存在。 |
400 |
LaunchTemplateSet.NotFound |
The specified launch template set is not found. |
指定實(shí)例啟動(dòng)模板不存在。 |
400 |
TemplateMissingParameter.ImageId |
The input parameter "ImageId" that is mandatory for processing this request is not supplied. |
實(shí)例啟動(dòng)模板指定版本缺少鏡像信息。 |
400 |
TemplateMissingParameter.InstanceTypes |
The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied. |
實(shí)例啟動(dòng)模板指定版本缺少實(shí)例規(guī)格信息。 |
400 |
TemplateMissingParameter.SecurityGroup |
The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied. |
實(shí)例啟動(dòng)模板指定版本缺少安全組信息。 |
400 |
TemplateVersion.NotNumber |
The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number. |
指定實(shí)例啟動(dòng)模板固定版本號(hào)為非數(shù)字。 |