All Products
Search
Document Center

Server Load Balancer:CreateMasterSlaveServerGroup

Last Updated:Oct 10, 2024

Creates a primary/secondary server group. Each primary/secondary server group consists of two backend servers. One backend server functions as the primary server, and the other backend server functions as the secondary backend server.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
slb:CreateMasterSlaveServerGroupcreate
  • Instance
    acs:ecs:{#regionId}:{#accountId}:instance/{#InstanceId}
  • LoadBalancer
    acs:slb:{#regionId}:{#accountId}:loadbalancer/{#LoadBalancerId}
  • slb:tag
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

cn-hangzhou
LoadBalancerIdstringYes

The CLB instance ID.

lb-bp1hv944r69al4j******
MasterSlaveServerGroupNamestringNo

The name of the primary/secondary server group.

Group1
MasterSlaveBackendServersstringYes

The backend servers in the primary/secondary server group. Each primary/secondary server group consists of two backend servers.

Configure the following parameters:

  • ServerId: required. The IDs of the backend servers. Specify the IDs in a string. You can specify the IDs of Elastic Compute Service (ECS) instances, elastic network interfaces (ENIs), and elastic container instances. If you set ServerId to the IDs of ENIs or elastic container instances, you must configure the Type parameter.

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

  • Description: optional. The description of the backend servers. Specify the description in a string. The description must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/). periods (.), and underscores (_).

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

    • ecs (default): ECS instance
    • eni: ENI
    • eci: elastic container instance
Note You can specify ENIs and elastic container instances as backend servers only for high-performance CLB instances.
  • ServerIp: the IP address of the ENI or elastic container instance.

  • Port: the backend port.

  • ServerType: Specify the primary and secondary backend servers in a string. 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" }]
Tagarray<object>No

The tags.

objectNo
KeystringNo

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

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

test
ValuestringNo

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

1

Response parameters

ParameterTypeDescriptionExample
object
MasterSlaveServerGroupIdstring

The ID of the active/standby server group.

rsp-bp19au4******
RequestIdstring

The request ID.

7CA4DB76-4D32-523B-822E-5C9494613D46
MasterSlaveBackendServersarray<object>

The backend servers in the primary/secondary server group.

MasterSlaveBackendServerobject
Typestring

The type of backend server. Valid values:

  • ecs: ECS instance
  • eni: ENI
  • eci: elastic container instance
ecs
Weightinteger

The weight of the backend server.

100
Descriptionstring

The description of the primary/secondary server group.

test-112
Portinteger

The port that is used by the backend server.

82
ServerIdstring

The ID of the backend server that you want to add.

i-bp1fq61enf4loa5i****
ServerTypestring

The type of backend server.

Valid values: Master and Slave.

Master

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
400BACKEND_SERVERS_NUM_MUST_BE_TWOBackend servers num must be 2.
400Mismatched.ZoneIdThe zone of the server is not matched with the cloud box loadbalancer.
400BACKEND_SERVERS_HAVE_SAME_PORT_AND_SERVERIDBackend servers have same port and serverId.
400BACKEND_SERVERS_CAN_ONLY_CONTAIN_ONE_MASTER_AND_ONE_SLAVEBackend servers can only contain one master and one slave.
400BACKEND_SERVER_ID_CAN_NOT_EMPTYBackend server id can not empty.
400INVALID_SERVER_TYPEInvalid server type.
400BACKEND_SERVER_PORT_CAN_NOT_EMPTYBackend server port can not empty.
400RealServerPortNotSupportReal server port not support.
400OperationUnsupported.CreateMasterSlaveServerGroupThis type of backend server is not allowed to attached to singleTunnel or anyTunnel lb.
400IncorrectStatus.RSByPassToas%s.
400OperationFailed.ActionNotSupportThe loadbalancer does not support such action.
400RsTunnelIp2VmNameConflict%s.
400NetworkConflict%s.
400InvalidParam.TagValue %s.
400InvalidParam.TagKey%s.
400SizeLimitExceeded.Tag%s.
400MissingParam.TagKeyThe param MissingParam.TagKey is missing.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-06-02The Error code has changedView Change Details