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 parameters

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 Server Load Balancer (SLB) instance.

MasterSlaveBackendServers String Yes [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","ServerType":"Master","Description":"test-112" }, { "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","ServerType":"Slave","Description":"test-112" }]

The 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: Required. Specify the ID of the backend server. This parameter must be of the STRING type.
  • Port: 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: Required. Specify the weight of the backend server. This parameter must be of the INTEGER type. Valid values: 0 to 100.
  • Description: 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 (_). It can also contain Chinese characters.
  • ServerType: Specify the backend server to be a primary server or secondary server. This parameter must be of the STRING type. Valid values:
    • Master: primary server
    • Slave: secondary server
  • Type: Specify the type of the backend server. This parameter must be of the STRING type. Valid values:
    • ecs: an ECS instance. This is the default value.
    • eni: an Elastic Network Interface (ENI).
  • ServerIp: the IP address of the ECS instance or ENI.

A primary/secondary server group can contain a maximum of two backend servers.

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

Examples:

  • ECS instance: [{ "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port": "80", "ServerType": "Master", "Description": "test-112" }, { "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs", "Port":"80","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 SLB instance is deployed.

MasterSlaveServerGroupName String No Group1

The name of the primary/secondary server group.

Response parameters

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

The ID of the primary/secondary server group.

MasterSlaveBackendServers Array of MasterSlaveBackendServer

The backend servers in the primary/secondary server group.

MasterSlaveBackendServer
ServerId String vm-2h****

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

Port Integer 90

The port that is used by the backend server.

Weight Integer 100

The weight of the backend server.

ServerType String Slave

Indicates whether the backend server is a primary or secondary server.

Valid values: Master and Slave. Default value: Master.

Description String Primary/SecondaryServerGroupDescription.

The description of the primary/secondary server group.

Type String ecs

The type of backend server. Valid values:

  • ecs: an ECS instance. This is the default value.
  • eni: an ENI.
RequestId String 9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C

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":"80","ServerType":"Master","Description":"test-112" },  { "ServerId": "i-xxxxxxxxx", "Weight": "100", "Type": "ecs",  "Port":"80","ServerType":"Slave","Description":"test-112" }]
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<CreateMasterSlaveServerGroupResponse>
      <RequestId>9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C</RequestId>
      <MasterSlaveServerGroupId>rsp-cige******</MasterSlaveServerGroupId>
      <MasterSlaveBackendServers>
            <MasterSlaveBackendServers>
        	      <ServerId>vm-gtgt***</ServerId>
        	      <Port>80</Port>
        	      <Weight>100</Weight>
			      <ServerType>Master</ServerType>
            </MasterSlaveBackendServers>
            <MasterSlaveBackendServers>
        	      <ServerId>vm-tygtyg****</ServerId>
        	      <Port>90</Port>
        	      <Weight>100</Weight>
			      <ServerType>Slave</ServerType>
            </MasterSlaveBackendServers>
      </MasterSlaveBackendServers>
</CreateMasterSlaveServerGroupResponse>

JSON format

{
  "CreateMasterSlaveServerGroup": {
    "RequestId": "9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C",
    "MasterSlaveServerGroupId": "rsp-cige6*****",
    "MasterSlaveBackendServers": {
      "MasterSlaveBackendServers": [
        {
          "ServerId": "vm-hhhh****",
          "Port": "80",
          "Weight": "100",
          "ServerType": "Master"
        },
        {
          "ServerId": "vm-gggg***",
          "Port": "90",
          "Weight": "100",
          "ServerType": "Slave"
        }
      ]
    }
  }
}

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 empty.
400 INVALID_SERVER_TYPE Invalid server type. The error message returned because the specified type of the 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.

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