Creates a primary/secondary server group. A primary/secondary server group can contain only two Elastic Compute Service (ECS) instances: one of the ECS instances functions as the primary server and the other functions as the secondary server.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameter

Parameter Type Required Example Description
Action String Yes CreateMasterSlaveServerGroup

The operation that you want to perform.

Set the value to CreateMasterSlaveServerGroup.

LoadBalancerId String Yes lb-bp1hv944r69al4j******

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

MasterSlaveBackendServers String Yes [{ "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" }]

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

The value of this parameter must be a STRING list in the JSON format. You can specify up to 20 elements in each request.

  • ServerId: This parameter is required. Specify the ID of the backend server. This parameter must be of the STRING type.
  • Port: This parameter is required. Specify the port that is used by the backend server. This parameter must be of the INTEGER type. Valid values: 1 to 65535.
  • Weight: This parameter is required. Specify the weight of the backend server. This parameter must be of the INTEGER type. Valid values: 0 to 100.
  • Description: This parameter is optional. Specify the description of the backend server. This parameter must be of the STRING type. The description must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.),and underscores (_).
  • ServerType: Specify the type of the backend server. This parameter must be of the STRING type. Valid values:
    • Master: primary server
    • Slave: secondary server
  • Type: Specify the type of backend server. This parameter must be of the STRING type. Valid values:
    • ecs: an ECS instance
    • eni: an elastic network interface (ENI)
  • ServerIp: the IP address of the ECS instance or ENI

A primary/secondary server group can contain at most two backend servers.

If you do not set this parameter, an empty primary/secondary server group is created.

Examples:

  • ECS: [{ "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" }]
  • ENI: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "Port":"80","ServerType":"Master","Description":"test-112" }, { "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni", "ServerIp": "192.168.**.**", "Port":"80","ServerType":"Slave","Description":"test-112" }]
  • ENI with multiple IP addresses: [{ "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni","ServerIp": "192.168.**.**", "Port":"80","ServerType":"Master","Description":"test-112" }, { "ServerId": "eni-xxxxxxxxx", "Weight": "100", "Type": "eni","ServerIp": "192.168.**.**", "Port":"80","ServerType":"Slave","Description":"test-112" }]
RegionId String Yes cn-hangzhou

The ID of the region where the CLB instance is deployed.

MasterSlaveServerGroupName String No Group1

The name of the primary/secondary server group.

Response parameters

Parameter Type Example Description
MasterSlaveServerGroupId String rsp-bp19au4******

The ID of the primary/secondary server group.

MasterSlaveBackendServers Array of MasterSlaveBackendServer

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

MasterSlaveBackendServer
ServerId String i-bp1fq61enf4loa5i****

The ID of the ECS instance or ENI that is added.

Port Integer 82

The port number used by the backend server.

Weight Integer 100

The weight of the backend server.

ServerType String Master

The type of the backend server.

Valid values: Master and Slave.

Description String test-112

The description of the primary/secondary server group.

Type String ecs

The type of the backend server. Valid values:

  • ecs: an ECS instance
  • eni: an ENI
RequestId String 7CA4DB76-4D32-523B-822E-5C9494613D46

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateMasterSlaveServerGroup
&LoadBalancerId=lb-bp1hv944r69al4j******
&MasterSlaveBackendServers=[{ "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" }]
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<CreateMasterSlaveServerGroupResponse>
  <RequestId>7CA4DB76-4D32-523B-822E-5C9494613D46</RequestId>
  <MasterSlaveServerGroupId>rsp-bp19au4******</MasterSlaveServerGroupId>
  <MasterSlaveBackendServers>
        <MasterSlaveBackendServer>
              <ServerType>Master</ServerType>
              <Type>ecs</Type>
              <ServerId>i-bp1fq61enf4loa5i****</ServerId>
              <Description>test-112</Description>
              <Port>82</Port>
              <Weight>100</Weight>
        </MasterSlaveBackendServer>
        <MasterSlaveBackendServer>
              <ServerType>Slave</ServerType>
              <Type>ecs</Type>
              <ServerId>i-bp10ephck4n5uehd****</ServerId>
              <Description>test-112</Description>
              <Port>84</Port>
              <Weight>100</Weight>
        </MasterSlaveBackendServer>
  </MasterSlaveBackendServers>
</CreateMasterSlaveServerGroupResponse>

JSON format

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

Error codes

HttpCode Error code Error message Description
400 BACKEND_SERVERS_NUM_MUST_BE_TWO Backend servers num must be 2. The error message returned because two backend servers must be specified.
400 BACKEND_SERVERS_HAVE_SAME_PORT_AND_SERVERID Backend servers have same port and serverId. The error message returned because a backend server with the same port and ID is already specified in the server group.
400 BACKEND_SERVERS_CAN_ONLY_CONTAIN_ONE_MASTER_AND_ONE_SLAVE Backend servers can only contain one master and one slave. The error message returned because a primary/secondary 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 error message returned because the ID of the backend server is not specified.
400 INVALID_SERVER_TYPE Invalid server type. The error message returned because the specified type of backend server is invalid.
400 BACKEND_SERVER_PORT_CAN_NOT_EMPTY Backend server port can not empty. The error message returned because the port of the backend server is not specified.
400 RealServerPortNotSupport Real server port not support. The error message returned because the specified port of the backend server is invalid.
400 OperationUnsupported.CreateMasterSlaveServerGroup This type of backend server is not allowed to attached to singleTunnel or anyTunnel lb. The error message returned because the backend server cannot be added to a CLB instance of the singleTunnel or anyTunnel type.
400 IncorrectStatus.RSByPassToas %s. The error message returned because the BypassToa parameter of the specified backend server is set to an invalid value.
400 OperationFailed.ActionNotSupport The loadbalancer does not support such action. The error message returned because the instance does not support the operation.
400 RsTunnelIp2VmNameConflict %s. The error message returned because a backend server uses the same TunnelId and RsIp configurations as an existing backend server.
400 NetworkConflict %s. The error message returned because the vServer group configurations are inconsistent with the ECS configurations.

For a list of error codes, visit the API Error Center.