All Products
Search
Document Center

Server Load Balancer:CreateMasterSlaveServerGroup

Last Updated:Sep 08, 2026

Creates a primary/secondary server group. A primary/secondary server group can contain only two backend servers: one primary server and one secondary server.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

slb:CreateMasterSlaveServerGroup

create

Instance

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

*LoadBalancer

acs:slb:{#regionId}:{#accountId}:loadbalancer/{#LoadBalancerId}

  • slb:tag
None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the Classic Load Balancer (CLB) instance.

cn-hangzhou

LoadBalancerId

string

Yes

The Classic Load Balancer (CLB) instance ID.

lb-bp1hv944r69al4j******

MasterSlaveServerGroupName

string

No

The name of the primary/secondary server group.

Group1

MasterSlaveBackendServers

string

No

The list of backend servers in the primary/secondary server group. A primary/secondary server group can contain only two backend servers.

The following parameters are included:

  • ServerId: String, required. The instance ID of the backend server. Valid values include ECS instance IDs, ENI instance IDs, and ECI instance IDs. When the value of ServerId is an ENI instance ID or an ECI instance ID, the Type parameter is required.

  • Weight: The weight of the backend server. Valid values: 0 to 100. Default value: 100. If the value is 0, no requests are forwarded to the backend server.

  • Description: String, optional. The description of the backend server. The description must be 1 to 80 characters in length and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_). Chinese characters are supported.

  • Type: The server type of the backend server. Valid values:

    • ecs: ECS instance (default).

    • eni: elastic network interface controller (NIC) instance.

    • eci: elastic container instance.

Note

Only guaranteed-performance instances support adding eni and eci types of backend servers.

  • ServerIp: The IP address of the ENI or ECI instance.

  • Port: The backend port that is used to accept requests.

  • ServerType: String. The primary or secondary type of the backend server. Valid values:

    • Master: primary server.

    • Slave: secondary server.

[{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"82","ServerType":"Master","Description":"test-112" }, { "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"84","ServerType":"Slave","Description":"test-112" }]

Tag

array<object>

No

The list of tags.

object

No

The list of tags.

Key

string

No

The tag key of the resource. Valid values of N: 1 to 20. The tag key cannot be an empty string if specified.

The tag key can be up to 64 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

test

Value

string

No

The tag value of the resource. Valid values of N: 1 to 20. The tag value can be an empty string if specified. The tag value can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

1

Response elements

Element

Type

Description

Example

object

MasterSlaveServerGroupId

string

The ID of the primary/secondary server group.

rsp-bp19au4******

RequestId

string

The request ID.

7CA4DB76-4D32-523B-822E-5C9******

MasterSlaveBackendServers

object

MasterSlaveBackendServer

array<object>

The list of backend servers in the primary/secondary server group.

object

The list of backend servers in the primary/secondary server group.

Type

string

The server type of the backend server. Valid values:

  • ecs: ECS instance.

  • eni: elastic network interface controller (NIC) instance.

  • eci: elastic container instance.

ecs

Weight

integer

The weight of the backend server.

100

Description

string

The description of the primary/secondary server group.

test-112

Port

integer

The port used by the backend server.

82

ServerId

string

The instance ID of the backend server to be added.

i-bp1fq61enf4loa5i****

ServerType

string

The server type.

Valid values: Master or Slave.

Master

Examples

Success response

JSON format

{
  "MasterSlaveServerGroupId": "rsp-bp19au4******",
  "RequestId": "7CA4DB76-4D32-523B-822E-5C9******",
  "MasterSlaveBackendServers": {
    "MasterSlaveBackendServer": [
      {
        "Type": "ecs",
        "Weight": 100,
        "Description": "test-112",
        "Port": 82,
        "ServerId": "i-bp1fq61enf4loa5i****",
        "ServerType": "Master"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 BACKEND_SERVERS_NUM_MUST_BE_TWO Backend servers num must be 2. The number of backend servers must be 2.
400 Mismatched.ZoneId The zone of the server is not matched with the cloud box loadbalancer. The specified zoneId does not match.
400 BACKEND_SERVERS_HAVE_SAME_PORT_AND_SERVERID Backend servers have same port and serverId. A virtual server with the same port and server ID already exists in the backend server group.
400 BACKEND_SERVERS_CAN_ONLY_CONTAIN_ONE_MASTER_AND_ONE_SLAVE Backend servers can only contain one master and one slave. A primary/secondary virtual server group can contain only one primary server and one secondary server.
400 BACKEND_SERVER_ID_CAN_NOT_EMPTY Backend server id can not empty. The backend server ID cannot be empty.
400 INVALID_SERVER_TYPE Invalid server type.
400 BACKEND_SERVER_PORT_CAN_NOT_EMPTY Backend server port can not empty. The backend server port cannot be empty.
400 RealServerPortNotSupport Real server port not support. The backend server port is not supported.
400 OperationUnsupported.CreateMasterSlaveServerGroup This type of backend server is not allowed to attached to singleTunnel or anyTunnel lb. This type of backend server cannot be attached to a SingleTunnel or AnyTunnel SLB instance.
400 IncorrectStatus.RSByPassToas %s. The BypassToa configuration of the specified backend server is invalid.
400 OperationFailed.ActionNotSupport The loadbalancer does not support such action. The operation failed because IPv6 SLB instances do not support this operation.
400 RsTunnelIp2VmNameConflict %s.
400 NetworkConflict %s. A network conflict exists in the specified parameters. Check whether the parameters are correct and try again.
400 InvalidParam.TagValue %s.
400 InvalidParam.TagKey %s.
400 SizeLimitExceeded.Tag %s.
400 MissingParam.TagKey The param MissingParam.TagKey is missing.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.