You need to enable JavaScript to run this app.
导航

CreateServerGroup

最近更新时间2024.02.29 14:48:18

首次发布时间2022.05.20 22:13:42

API 说明

API 名称:CreateServerGroup。
API 域名:open.volcengineapi.com 。
API 描述:创建服务器组,每个账户最多创建50个服务器组。

使用限制

节流限制:每秒最多提交 40 个 API 请求。

快速调试

URI 参数

在使用该部分 API 提交请求时必须包含以下 URI 参数。

除了 URI 参数,该 API 请求还需要包含签名参数。关于更多签名参数的信息,参见公共请求参数

名称类型是否必选格式说明
Action
string
[a-zA-Z]+
API 名称,如 CreateServerGroup。
VersionstringYYYY-MM-DDAPI 版本信息。该参数的取值是 2020-04-01 。
X-Expiresint900表示签名的有效时间,单位是秒,默认值是900。

请求正文

在使用该 API 提交请求时,请求正文中可以包含的参数如下。

参数类型是否必选参数说明示例值
VpcId
String服务器组所属的 Vpc 的 ID 。
vpc-3th8z3ajkd4bwbhc****

ServerGroupName

String

后端服务器组的名称。

  • 必须以字母或中文开头,可包含数字、点号(.)、下划线(_)和短横线(-)。
  • 长度限制为1 ~ 128个字符。
  • 不传入该参数或该参数不传入数值时,默认为后端服务器组 ID。

default_servergroup

ServerGroupType

String

后端服务器组的类型。取值:

  • instance(默认值):服务器类型,该类型服务器组支持添加 ecs、eni 实例作为后端服务器。

  • ip:IP类型,该类型服务器组支持添加 IP 地址作为后端服务器。

instance

Description

String

后端服务器组的描述。

  • 必须以字母或中文开头,可包含数字、英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、短横线(-)、中文逗号(,)、中文句号(。)。
  • 长度限制为1 ~ 255个字符。
  • 不传入该参数或该参数不传入数值时,默认为空字符串。

This is the default servergroup

Scheduler

String

调度算法。取值:

  • wrr(默认值):加权轮询。
  • wlc:加权最小连接数。
  • sh:源地址哈希。

wrr

HealthCheck
Array of HealthCheck
服务器组绑定的健康检查配置参数。具体参见下表 HealthCheck-
StickySessionConfigArray of StickySessionConfig会话保持功能的配置参数。具体参见下表 StickySessionConfig-
ProjectNameString后端服务器组所属项目名称。default

HealthCheck

参数类型是否必选参数说明示例值
HealthCheck.Enabled

String

监听器是否开启健康检查功能。取值如下:

  • on:开启(默认值)。

  • off:不开启。

on
HealthCheck.IntervalInteger开启健康检查后,执行健康检查的时间间隔。 单位:秒,取值:1~300s,默认值为 2。2

HealthCheck.Timeout

Integer

开启健康检查后,健康检查的响应超时时间。

  • 表示如果后端服务器在指定的时间内没有正确响应,则判定为健康检查异常。

  • 响应超时时间需小于等于检查时间间隔。

  • 单位:秒,取值:1~60,默认值为 2。

2

HealthCheck.HealthyThreshold

Integer

开启健康检查后,健康检查的健康阈值。

  • 表示连续执行指定次数的健康检查,结果均为正常的后端服务器将判定为健康检查正常。

  • 单位:次,取值:2~10,默认值为 3。

3

HealthCheck.UnhealthyThreshold

Integer

开启健康检查后,健康检查的不健康阈值。

  • 表示连续执行指定次数的健康检查,结果均为异常的后端服务器将判定为健康检查异常。

  • 单位:次,取值:2~10,默认值为 3。

3

HealthCheck.Method

String

开启健康检查后,健康检查的方法。取值如下:

  • GET:服务器需支持GET方法。

  • HEAD(默认):服务器仅返回HEAD头部信息,可以降低后端性能消耗,但服务器需要支持HEAD方法。

HEAD

HealthCheck.Domain

String

健康检查的域名,需配置为后端服务器上真实对外提供服务的地址。

  • 需至少包含一个‘.’,且不允许以‘.’开头或结尾。

  • 域名每一级由字母、数字、‘-’、‘.’字符组成,且‘-’不得出现在每一级的头部或尾部。

  • 长度限制为1 ~ 128个字符。

  • 不传入该参数或该参数不传入数值时,默认为空,表示负载均衡使用各后端服务器的私网IP地址进行健康检查。

www.test.com

HealthCheck.URI

String

健康检查的路径,需配置为后端服务器上真实对外提供的路径。

  • 必须以字符‘/’开头。

  • 仅包含字母、数字、‘-’、‘_’、‘/’、‘.’、‘%’、‘?’、‘#’、‘&’、‘=’ 字符。

  • 长度限制为1 ~ 128个字符。

  • 不传入该参数或该参数不传入数值时,默认为“/”。

/health

HealthCheck.HttpCode

String

健康检查正常的HTTP状态码。多个状态码间用半角逗号","分隔。取值如下:

  • http_2xx(默认值)。

  • http_3xx(默认值)。

  • http_4xx 。

  • http_5xx 。

"http_2xx,http_3xx"

HealthCheck.ProtocolString健康检查协议,当前支持HTTP。默认值为 HTTP。HTTP

HealthCheck.HttpVersion

String

健康检查HTTP协议版本,取值如下:

  • HTTP1.0(使用API时,HTTP协议版本默认值)。

  • HTTP1.1。

HTTP1.0

StickySessionConfig

参数类型是否必选参数说明示例值

StickySessionConfig.StickySessionEnabled

String

是否开启会话保持。取值如下:

  • on:开启;

  • off(默认值):关闭。

off

StickySessionConfig.StickySessionType

String

对 Cookie 的处理方式。当 StickySessionConfig.StickySessionEnabled 值为 on 时,此字段参数必填。取值如下:

  • insert(默认值):植入 Cookie;

    ALB 会记录客户端请求第一次转发到的后端服务器。ALB 在返回请求中植入 Cookie ,后续客户端请求携带此 Cookie,ALB 会将请求转发到之前记录的后端服务器上。

  • server:重写 Cookie;

    开启重写 Cookie 的会话保持后,在客户端请求第一次转发到后端服务器后,ALB 在返回请求中发现您自定义的 Cookie 时,会对原来的 Cookie 进行重写。后续客户端请求携带改写后的 Cookie,ALB 会将请求转发到之前记录的后端服务器上。

insert

StickySessionConfig.Cookie

String

服务配置的会话保持 Cookie 名称。仅在开启会话保持功能并选择重写 Cookie 时有效。 具体规则如下:

  • Cookie 名称长度为1~200个字符。

  • 名称只能包含 ASCII 英文字母和数字字符,不能包含半角逗号(,)、半角分号(;)或空格,也不能以美元符号($)开头。

  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 server时,此参数必填。

  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 insert 时,该参数无效。

MY_COOKIE

StickySessionConfig.CookieTimeout

Integer

会话保持 Cookie 超时时间。仅在开启会话保持功能并选择植入 Cookie 时有效。 单位:秒。具体规则如下:

  • 超时时间的取值范围:1~86400。 默认值为:1000。

  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionConfig.StickySessionType 为 insert 时,此参数必填。

  • 当 StickySessionConfig.StickySessionEnabled 值为 on,且 StickySessionType 为 server 时,此参数无效。

1000

响应正文

参数类型参数说明示例值
RequestId
String
请求ID。
20210811152539010225146063030****
ServerGroupIdString后端服务器组ID。rsp-bp1o94dp5i6ea****

示例

请求示例

GET /?Action=CreateServerGroup&VpcId=vpc-3th8z3ajkd4bwbhc****&ServerGroupName=test&Scheduler=wrr&HealthCheck.HttpCode="http_2xx,http_3xx"&Version=2020-04-01 HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
ServiceName: alb

响应示例

{
    "ResponseMetadata": {
        "RequestId": "20210816110638****2514606306AF947C",
        "Action": "CreateServerGroup",
        "Version": "2020-04-01",
        "Service": "alb",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "202108161106****22514606306AF947C",
        "ServerGroupId": "rsp-2ff0jsqj1hslc5oxruuy09okg"
    }
}

错误码

如果响应正文包含 Error 字段,则表示 API 请求失败。此处仅展示当前 API 的错误码,更多错误码请参见公共错误码

HTTP Code

错误码

错误信息

错误描述

400

InvalidServerGroupName.Malformed

The specified ServerGroupName is malformed.

指定的 ServerGroupName 参数格式不合法。

400InvalidDescription.MalformedThe specified Description is malformed.指定的 Description 参数格式不合法。
400InvalidScheduler.MalformedThe specified Scheduler is malformed.指定的 Scheduler 参数格式不合法。
400InvalidServerGroupType.MalformedThe specified ServerGroupType is malformed.指定的 ServerGroupType 参数格式不合法。
400InvalidStickySessionConfig.StickySessionEnabled.MalformedThe specified StickySessionConfig.StickySessionEnabled is malformed.指定的 StickySessionConfig.StickySessionEnabled 参数格式不合法。
400InvalidStickySessionConfig.StickySessionType.MalformedThe specified StickySessionConfig.StickySessionType is malformed.指定的 StickySessionConfig.StickySessionType 参数格式不合法。

400

MissingParameter

The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, 'StickySessionConfig.Cookie'.

该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如: StickySessionConfig.Cookie。

400

InvalidStickySessionConfig.Cookie.Malformed

The specified StickySessionConfig.Cookie is malformed.

指定的 StickySessionConfig.Cookie 参数格式不合法。

400InvalidStickySessionConfig.CookieTimeout.MalformedThe specified StickySessionConfig.CookieTimeout is malformed.指定的 StickySessionConfig.CookieTimeout 参数格式不合法。
400InvalidHealthCheck.Enabled.MalformedThe specified HealthCheck.Enabled is malformed.指定的 HealthCheck.Enabled 参数格式不合法。
400InvalidHealthCheck.Interval.MalformedThe specified HealthCheck.Interval is malformed.指定的 HealthCheck.Interval 参数格式不合法。
400InvalidHealthCheck.Timeout.MalformedThe specified HealthCheck.Timeout is malformed.指定的 HealthCheck.Timeout 参数格式不合法。
400InvalidHealthCheck.HealthyThreshold.MalformedThe specified HealthCheck.HealthyThreshold is malformed.指定的 HealthCheck.HealthyThreshold 参数格式不合法。

400

InvalidHealthCheck.UnhealthyThreshold.Malformed

The specified HealthCheck.UnhealthyThreshold is malformed.

指定的 HealthCheck.UnhealthyThreshold 参数格式不合法。

400InvalidHealthCheck.Protocol.MalformedThe specified HealthCheck.Protocol is malformed.指定的 HealthCheck.Protocol 参数格式不合法。
400OperationFailed.QueryProjectThe request on the specified resource failed due to the query on project failed.因查询项目失败,对于该资源的操作请求失败。

400

InvalidHealthCheck.Method.Malformed

The specified HealthCheck.Method is malformed.

指定的 HealthCheck.Method 参数格式不合法。

400InvalidHealthCheck.URI.MalformedThe specified HealthCheck.URI is malformed.指定的 HealthCheck.URI 参数格式不合法。
400InvalidHealthCheck.HttpCode.MalformedThe specified HealthCheck.HttpCode is malformed.指定的 HealthCheck.HttpCode 参数格式不合法。

400

InvalidHealthCheck.Domain.Malformed

The specified HealthCheck.Domain is malformed.

指定的 HealthCheck.Domain 参数格式不合法。

400

QuotaExceed.ServerGroupPerRegion

You've reached the limit on the number of server groups the current region you can create in, usage xx/xx.

已达到当前地域可创建服务器组的数量上限。目前已使用xxx,配额为xxx。

400OperationFailed.AddIntoProjectFailedThe request on the specified resource failed due to adding it into the project failed.因将资源加入至项目中失败,对于该资源的操作请求失败。
400InvalidHealthCheck.HttpVersion.MalformedThe specified HealthCheck.HttpVersion is malformed.指定的 HealthCheck.HttpVersion 参数格式不合法。

400

MissingParameter

The request is missing a required parameter. Ensure that you have supplied all the required parameters for the request; for example, 'HealthCheck.Domain'.

该请求缺少必要参数。请确保发起请求已提供全部必要参数,比如: HealthCheck.Domain。

403

Forbidden

You are not authorized to create ServerGroup with the type of ip.

您无权限创建 IP 类型的服务器组。

404

InvalidVpc.NotFound

The specified VPC does not exist.

指定的 VPC 不存在。

404InvalidProject.NotFoundThe specified Project does not exist.指定的项目不存在。