全部產品
Search
文件中心

Server Load Balancer:AddServersToServerGroup - 添加後端伺服器

更新時間:Oct 10, 2025

向伺服器組中添加後端伺服器。

介面說明

AddServersToServerGroup 介面屬於非同步介面,即系統返回一個請求 ID,但該後端伺服器尚未添加成功,系統背景新增工作仍在進行。

  1. 您可以調用 ListServerGroups 查詢服務器組的狀態:

  • 當伺服器組處於 Configuring 狀態時,表示伺服器組正在變更配置中。

  • 當伺服器組處於 Available 狀態時,表示伺服器組運行中。

  1. 您可以調用 ListServerGroupServers 查詢後端伺服器的狀態:

  • 當後端伺服器處於 Adding 狀態時,表示後端伺服器正在加入伺服器組。

  • 當後端伺服器處於 Available 狀態時,表示後端伺服器運行中。

調試

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

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

alb:AddServersToServerGroup

create

*ServerGroup

acs:alb:{#regionId}:{#accountId}:servergroup/{#servergroupId}

Instance

acs:alb:{#regionId}:{#accountId}:ecs/{#InstanceId}

NetworkInterface

acs:alb:{#regionId}:{#accountId}:eni/{#NetworkInterfaceId}

ContainerGroup

acs:alb:{#regionId}:{#accountId}:eci/{#ContainerGroupId}

請求參數

名稱

類型

必填

描述

樣本值

ServerGroupId

string

伺服器組 ID。

sgp-atstuj3rtop****

Servers

array<object>

後端伺服器列表, 單次調用最多支援添加 200 個伺服器。

object

後端伺服器組結構體。

Description

string

後端伺服器描述。長度為 2~256 個英文或中文字元,不能以 http://和 https://開頭。

test

Port

integer

後端伺服器使用的連接埠。取值範圍:1~65535。 單次調用最多支援添加 200 個伺服器。

說明

ServerType 取值為 EcsEniEciIp 時,該參數必傳。當 ServerType 取值為 Fc 時,無需配置該參數。

80

ServerId

string

後端伺服器 ID。 單次調用最多支援添加 200 個伺服器。

  • 當伺服器組為 Instance 類型時,該參數為 EcsEniEci 的資源 Id。

  • 當伺服器組為 Ip 類型時,該參數為 IP 位址。

  • 當伺服器組為 Fc 時,該參數為Function Compute的 ARN 標識。

i-uf616vu8me******

ServerIp

string

指定 IP 位址。 單次調用最多支援添加 200 個伺服器。

ServerTypeEni 時,支援指定 ENI 的主私網 IP 或輔助私網 IP。

說明

ServerType 取值為 Fc 時,無需配置該參數。

192.168.1.1

ServerType

string

後端伺服器類型。 單次調用最多支援添加 200 個伺服器。取值:

  • Ecs:ECS 執行個體。

  • Eni:ENI 彈性網卡執行個體。

  • Eci:ECI 彈性容器。

  • Ip:IP 位址。

  • Fc:Function Compute。

Ecs

Weight

integer

後端伺服器的權重,取值範圍:0~100。預設值為 100。如果設定權重為 0,則不會將請求轉寄給該後端伺服器。 單次調用最多支援添加 200 個伺服器。

說明

ServerType 取值為 Fc 時,無需配置該參數。

100

RemoteIpEnabled

boolean

是否開啟遠端 IP 功能。 單次調用最多支援添加 200 個伺服器。取值:

  • true:開啟。

  • false:不開啟。

說明

ServerType 取值為 Ip 時,該參數有效。

false

ClientToken

string

用戶端 Token,用於保證請求的等冪性。

從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。

說明

若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 標識。每次 API 請求的 RequestId 不一樣。

593B0448-D13E-4C56-AC0D-FDF0******

DryRun

boolean

是否只預檢此次請求,取值:

  • true:發送檢查請求,不會向伺服器組中添加後端伺服器。檢查項包括是否填寫了必需參數、請求格式、業務限制。如果檢查不通過,則返回對應錯誤。如果檢查通過,則返回錯誤碼DryRunOperation

  • false(預設值):發送正常請求,通過檢查後返回 HTTP 2xx 狀態代碼並直接進行操作。

false

返回參數

名稱

類型

描述

樣本值

object

返回資料結構體

JobId

string

非同步任務 ID。

72dcd26b-f12d-4c27-b3af-18f6aed5****

RequestId

string

請求 ID。

365F4154-92F6-4AE4-92F8-7FF34******

樣本

正常返回樣本

JSON格式

{
  "JobId": "72dcd26b-f12d-4c27-b3af-18f6aed5****",
  "RequestId": "365F4154-92F6-4AE4-92F8-7FF34******"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 ResourceQuotaExceeded.ServerAddedNum The quota of %s is exceeded for resource %s, usage %s/%s. 伺服器添加到組已超額度限制。
400 IncorrectStatus.ServerGroup The status of %s [%s] is incorrect. 伺服器組狀態無效。
400 Conflict.BackendServer There is already %s having the same configuration with %s. 伺服器衝突,已經存在同配置的後端伺服器。
400 OperationDenied.VpcVportNotFound The operation is not allowed because of %s. 不允許該操作,原因:vpc連接埠未找到
400 IncorrectStatus.Eni The status of %s [%s] is incorrect. 資源%s [%s]的狀態無效。
400 ResourceInUse.IP The specified resource %s is in use. 資源%s正在使用中。
400 OperationDenied.NoAvailableVSwitch The operation is not allowed because of %s. 操作被拒絕,原因是%s。
400 OperationDenied.VgwVipNotFound The operation is not allowed because of %s. 操作被拒絕,原因是%s。
400 OperationDenied.CloudBox The operation is not allowed because of %s. 操作被拒絕,原因是%s。
400 Mismatch.Type The %s is mismatched for %s and %s. %s在%s和%s中不匹配。
400 Mismatch.VpcId The %s is mismatched for %s and %s. %s在%s和%s中不匹配。
400 ResourceQuotaExceeded.LoadBalancerServersNum The quota of %s is exceeded for resource %s, usage %s/%s. 後端伺服器數已超額度限制。
400 ResourceInConfiguring The specified resource of %s is being configured. Please try again later. 指定的資源在變更中,請稍後再試
400 DuplicatedParam.BackendServer The param of %s is duplicated. 參數%s是重複的。
400 OperationDenied.EciNotSupportJobType The operation is not allowed because of eci not support job type. 伺服器組不支援添加Job最佳化型ECI執行個體。
400 IllegalParam.ServerIp The param of ServerIp is illegal. 參數ServerIp非法
400 Mismatch.ServerType The %s is mismatched for %s and %s. %s在%s和%s中不匹配。
400 ServiceUnavailable The request has failed due to a temporary failure of the server. 請求因伺服器暫時性故障而失敗。
403 Forbidden.ServerGroup Authentication has failed for ServerGroup. 對ServerGroup鑒權失敗
404 ResourceNotFound.ServerGroup The specified resource %s is not found. 後端伺服器組不存在。
404 ResourceNotFound.Ecs The specified resource %s is not found. Ecs伺服器不存在。
404 ResourceNotFound.Eci The specified resource %s is not found. Eci伺服器不存在。
404 ResourceNotFound.Eni The specified resource %s is not found. 資源%s不存在。

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

變更歷史

更多資訊,參考變更詳情