用于创建一个新的负载均衡器实例,支持自定义路由策略、会话保持、监控配置等高级功能。
接口说明
通过此 API,用户可以根据业务需求配置负载均衡服务,包括但不限于自适应路由、加权轮询、规则匹配、健康检查等设置,以实现流量的有效管理和优化。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action
元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:
- 对于必选的资源类型,用前面加 * 表示。
- 对于不支持资源级授权的操作,用
全部资源
表示。
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 |
---|---|---|---|---|
esa:CreateLoadBalancer | create | *Site acs:esa:{#regionId}:{#accountId}:site/{#SiteId} |
| 无 |
请求参数
名称 | 类型 | 必填 | 描述 | 示例值 |
---|---|---|---|---|
Name | string | 是 | 负载均衡器名称,需要满足域名格式校验,并且是站点下的子域名。 | lb.example.com |
Enabled | boolean | 否 | 负载均衡器是否启用。
| true |
SiteId | long | 是 | 站点 ID,可通过调用 ListSites 接口获取。 | 123456789**** |
AdaptiveRouting | object | 否 | 跨地址池回源配置。 | |
FailoverAcrossPools | boolean | 否 | 是否跨地址池回源。
| true |
DefaultPools | array | 是 | 默认地址池列表。 | |
long | 是 | 默认地址池 ID,整型。 | 95223818027**** | |
FallbackPool | long | 是 | 兜底地址池 ID,当所有其他池不可用时,流量将被导向此处。 | 123 |
RandomSteering | object | 否 | 加权轮询配置,用于控制不同地址池的流量分配权重。 | |
DefaultWeight | integer | 否 | 默认的轮询权重,用于所有没有单独指定权重的地址池。取值范围:0-100 之间的整数。 | 50 |
PoolWeights | object | 否 | 各后端服务器池的权重配置,键为池 ID,值为权重系数。权重系数表示相对流量分配的比例。 | |
integer | 否 | 单个源地址池的权重,0-100 的数字,0 表示不往该源地址池调度流量。 | 50 | |
Rules | array<object> | 否 | 规则信息。 | { "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
object | 否 | 规则结构体。 | ||
RuleName | string | 否 | 规则名称。添加全局配置的时候不需要设置该参数。 | rule_1 |
Rule | string | 否 | 规则内容,使用条件表达式来匹配用户请求。添加全局配置的时候不需要设置该参数。存在两种使用场景:
| (http.request.method eq "GET" and http.request.version eq "HTTP/1.0") or (ip.geoip.country eq "CN") or (http.host eq "www.example.com") |
RuleEnable | string | 否 | 规则开关。添加全局配置的时候不需要设置该参数。取值范围:
| on |
FixedResponse | object | 否 | 匹配规则后执行响应指定内容。 | |
ContentType | string | 否 | HTTP Header 中的 Content-Type 字段。 | application/octet-stream |
Location | string | 否 | HTTP 返回中的 location 字段。 | http://www.example.com/index.html |
MessageBody | string | 否 | 响应 body 值。 | Hello World! |
StatusCode | integer | 否 | 响应状态码。 | 200 |
Overrides | any | 否 | 匹配规则后修改对应请求改写的负载均衡配置,配置的字段,会覆盖负载均衡器配置里相应的字段。 | { "adaptive_routing": { "failover_across_pools": true }, "sub_region_pools": { "AL,AT": [ 92298024898****, 92304347804**** ], "BG,BY": [ 92298024898**** ] }, "default_pools": [ 92298024898****, 92304347804**** ], "fallback_pool": 92298024898****, "location_strategy": { "mode": "resolver_ip", "prefer_ecs": "always" }, "random_steering": { "default_weight": 0.3, "pool_weights": { "92298024898****": 0.7, "92304347804****": 0.8 } }, "region_pools": { "CN,SEAS": [ 92298024898****, 92304347804**** ], "SAF,SAS": [ 92304347804**** ] }, "session_affinity": "ip", "steering_policy": "geo", "ttl": 30 } |
Sequence | integer | 否 | 规则执行顺序,可以不填,不填时以列表顺序执行,如果填的话,是大于 0 的整数。数值越大越优先执行。 | 1 |
Terminates | boolean | 否 | 是否终止执行后续规则。
| true |
SessionAffinity | string | 否 | 会话保持,取值:
| ip |
SteeringPolicy | string | 是 | 负载均衡策略。
| order |
Description | string | 否 | 负载均衡器的详细描述信息,便于管理和识别。 | 测试负载均衡器描述 |
Ttl | integer | 否 | TTL 值,DNS 记录的生存时间,默认为 30 秒。取值范围:10-600。 | 300 |
Monitor | object | 是 | 监视器配置,用于健康检查。 | |
Type | string | 否 | 监视器协议类型,如 HTTP,用于健康检查,值为 off 时,表示不进行检查。
| HTTP |
Method | string | 否 | 监视器请求方法,如 | GET |
Port | integer | 否 | 源站端口。 | 1921 |
Path | string | 否 | 监视器检查路径,如 | /health |
Interval | integer | 否 | 监视间隔,如 | 60 |
Timeout | integer | 否 | 应用健康检查超时时间,单位为秒,取值范围:1-10。 | 5 |
ExpectedCodes | string | 否 | 预期状态码,如 | 200 |
FollowRedirects | boolean | 否 | 是否跟随重定向。
| true |
ConsecutiveUp | integer | 否 | 连续探测多少次成功算成功,如 | 3 |
ConsecutiveDown | integer | 否 | 连续探测多少次失败算失败,如 | 5 |
Header | any | 否 | 探测时所带头部信息,HTTP 头。 | { "host": [ "example1.com", "example2.com" ] } |
SubRegionPools | any | 否 | 二级 region 对应的地址池,多个二级 region 共用一批地址池时,可以多个二级 region,使用逗号拼接作为 key。 | {"AL,MO": [92298024898****],"CN-SH,CN-SX,CN-SC":[92304347804****,92843536908****]} |
RegionPools | any | 否 | 一级 region 对应的地址池。 | { "ENAM": [ 12345678**** ], "WNAM": [ 23456789****, 23456789**** ] } |
返回参数
示例
正常返回示例
JSON
格式
{
"RequestId": "EEEBE525-F576-1196-8DAF-2D70CA3F4D2F\n",
"Id": 0
}
错误码
HTTP status code | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | InvalidParameter | The specified parameter is invalid. | 输入参数规范校验失败。 |
400 | LoadBalancerQuotaCheckFailed | Load balancer enable quota check failed. | 您当前的套餐无法使用负载均衡器相关功能,如需使用,请进行套餐升级。 |
400 | LoadBalancerNumberExceedQuotaLimit | The number of load balancers you have added has reached the limit of the plan quota. Please delete the unused load balancers or upgrade the plan and try again. | 您添加的负载均衡器数量已经达到套餐配额限制,请删除不使用的负载均衡器或者升级套餐后进行重试。 |
400 | LoadBalancerRuleQuotaCheckFailed | Your current plan does not support configuring load balancer custom rules, or the load balancer rules you have added exceed the plan quota limit. Please upgrade the plan or delete the rules that are no longer in use and try again. | 您当前的套餐不支持配置负载均衡器自定义规则,或者您已经添加的负载均衡器规则超过套餐配额限制,请升级套餐或者删除不再使用的规则后重试。 |
400 | LoadBalancerPolicyCheckFailed | Your current plan does not support the load balancer scheduling policy. Upgrade the plan and try again. | 您当前的套餐不支持使用该负载均衡器调度策略,请升级套餐后重试。 |
400 | LoadBalancerHealthDetectionQuotaCheckFailed | Your current plan does not allow you to configure the load balancer's health detection. Upgrade the plan and try again. | 您当前的套餐不允许配置负载均衡器的健康探测,请升级套餐后重试。 |
400 | LoadBalancerHealthDetectionIntervalCheckFailed | The configured load balancer health detection interval exceeds the quota range allowed by the plan. Please revise the interval within the range or upgrade the plan and try again. | 您配置的负载均衡器健康探测时间间隔超出了套餐允许的配额范围,请订正为范围内的间隔或者升级套餐后,进行重试。 |
400 | InternalException | Failed to call the service. Try again later or contact technical support. | 调用服务失败,请稍后重试或联系客服咨询详情。 |
400 | Instance.NotOnline | Your plan is unavailable due to an overdue payment. Complete the payment first. | 您的套餐实例因欠费当前处于非上线状态,请先完成续费操作以继续使用。 |
400 | MonitorExpectedBodyInvalid | Invalid response body. Specify a response body that does not exceed 102,400 characters in length in your custom rule. | 传入的监视器预期返回值不正确,长度不能大于102400字符,请您确认返回值后重试。 |
400 | MonitorExpectedCodesInvalid | Invalid expected status code for the probe.Make sure that you specify no more than 10 status codes in the probe settings, and each status code must be 3 to 4 characters in length.Examples: 200, 301, 3xx, 8000, and 88xx. | 传入的监视器预期返回码不合法。请注意:返回码的数量不能超过10个,且每个返回码的长度应不少于3个字符且不超过4个字符。例如:200、301、3xx、8000、88xx。 |
400 | MonitorHeaderInvalid | Invalid request header for the probe. You can add up to 10 request headers, each with 1 to 9 values. The combined length of all headers and values cannot exceed 6,000 characters. You cannot configure the User-Agent header. | 传入的监视器携带的请求头非法。请确保请求头数量不超过10个,每个请求头的值长度在1到10之间,并且不得使用User-Agent请求头(该请求头保留用于内部特定场景)。此外,所有请求头及其值的总长度不得超过6000个字符。请您检查并修正请求头配置后重试。 |
400 | MonitorMethodNotSupport | Invalid HTTP method for the probe request. Valid values are GET and HEAD. | 传入的监视器请求方法不支持,只支持以下方法:GET/HEAD。 |
400 | MonitorPathNotSupport | Invalid probe URL path.If you set the probe protocol to HTTP or HTTPS, make sure you specify a probe URL path that does not exceed 1,024 characters in length. | 传入的监听路径不支持。当监听类型为HTTP或HTTPS时,监听路径不能为空,且路径长度不得超过1024个字符,请您检查路径后重试。 |
400 | MonitorPortNotSupport | Invalid probe port. Specify a valid port from 1 to 65535 for the probe request. Then, try again. | 传入的监视器监听端口不支持,端口取值范围:[1-65535],请您确保端口在取值范围内重试。 |
400 | MonitorRetriesInvalid | Invalid number of probe retries. Specify an integer from 0 to 5. Then, try again. | 传入的监视器重试次数参数不支持,支持的重试次数取值范围为:[0-5],请确保设置的重试次数在此范围内。 |
400 | MonitorTimeoutInvalid | Invalid timeout for the probe. Valid values are 1 to 10. | 传入的监视器超时时间超出取值范围,支持以下范围:[1-10]。 |
400 | MonitorTypeNotSupport | Invalid protocol. Valid values are off, HTTP, HTTPS, TCP, UDP, ICMP Ping, and SMTP. | 传入的监视器类型不支持,监视器只支持以下类型:off/HTTP/HTTPS/TCP/UDP/ICMP Ping/SMTP。 |
400 | OriginPoolNotExist | The specified origin pool does not exist or does not belong to your account or website. Check and try again. | 传入的源地址池不存在,或该地址池不属于当前用户和站点,请您确认后重试。 |
400 | LoadBalancerNameConflict | The load balancer name or the hostname for the origin pool already exists. Try again with a unique name. | 负载均衡器名称或源地址池记录名已存在,请更换一个唯一的名字重试。 |
400 | LockFailed | The system is handling requests you previously submitted. Try again later. | 您有其他请求正在处理中,请稍后再进行重试。 |
400 | SourceCircleExist | The host record of the resource to be operated on is already the source station of another resource, or the source station of the current resource has been added as a host record. To avoid loopback, modify the host record or source station and retry. | 当前要操作资源的主机记录已经是其他资源的源站,或者当前资源的源站已经被添加为主机记录,为避免回环产生,请修改主机记录或者源站后进行重试。 |
403 | QuotaExceeded | The quota is exceeded. | 额度不足 |
404 | SiteNotFound | The website does not exist or does not belong to you. | 站点不存在,或者不属于你。 |
访问错误中心查看更多错误码。
变更历史
变更时间 | 变更内容概要 | 操作 |
---|---|---|
2025-02-13 | OpenAPI 错误码发生变更、OpenAPI 入参发生变更 | 查看变更详情 |
2025-02-10 | OpenAPI 错误码发生变更 | 查看变更详情 |