Description
You can call this operation to create a single tenant in a cluster.
Call description
Prerequisite
You have passed the authentication for the OCP application service.
Request path
POST /api/v2/ob/clusters/{id}/tenants
Path parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| id | Integer | Yes | 1 | The ID of the cluster. |
Request parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| name | String | Yes | foo | The name of the tenant, which is unique in the cluster. |
| mode | String | No | MYSQL | The compatibility mode of the tenant. Valid values: |
| primaryZone | String | No | zone1,zone2;zone3 | The priorities of the zones. |
| charset | String | No | utf8mb4 | The character set. Valid values:
|
| collation | String | No | utf8mb4_general_ci | The collation.
|
| description | String | No | bar | The description of the tenant. |
| whitelist | String | No | % | The whitelist of the tenant. Supported formats: IP address example: xxx.xxx.xxx.1,xxx.xxx.xxx.2 Subnet/mask example: xxx.xxx.xxx.1/24 Fuzzy match example: xxx.xxx.xxx.% or xxx.xxx.xxx.Mixed format example: xxx.xxx.xxx.1,xxx.xxx.xxx.2,xxx.xxx.xxx.1.xxx.xxx.xxx.,xxx.xxx.xxx.0/24 Note: % indicates that the tenant can access the database from any client. Default value: %. |
| rootPassword | String | Yes | The password of the administrator. For an Oracle tenant, this parameter specifies the password of the sys user. For a MySQL tenant, this parameter specifies the password of the root user. Password strength: The password must be 8 to 32 characters in length and contain at least two digits, two uppercase letters, two lowercase letters, and two of the following special characters: ._+@#$% | |
| saveToCredential | Boolean | No | true | Specifies whether to save the password of the tenant administrator to the password box of the current user logged on to OCP. |
| zones | Array | Yes | -- | -- |
| ├─name | String | Yes | zone1 | The name of the zone in the cluster. |
| ├─replicaType | String | Yes | FULL | The type of the replica. Valid values: |
| ├─resourcePool | Object | Yes | The resource pool. | |
| ├─unitSpecName | String | Yes | S1 | The unit specifications. You can view the unit specifications on the Unit Specification Management page. |
| ├─unitCount | Integer | Yes | 1 | The number of units. |
Response parameters
Basic data structure
| Parameter | Type | Description |
|---|---|---|
| data | Object | The information about the created tenant. |
| successful | Boolean | Indicates whether the request was successful. |
| timestamp | Datetime | The timestamp when the server completed the request. |
| duration | Integer | The time taken by the server to process the request, in milliseconds. |
| status | Integer | An HTTP status code. |
| traceId | String | The trace ID of the request. This trace ID is used for troubleshooting. |
| server | String | The address of the application server that responded to the request. |
Data structure of tenant information
| Parameter | Type | Description |
|---|---|---|
| id | Long | The ID of the tenant. |
| name | String | The name of the tenant. |
| clusterName | String | The name of the cluster. |
| obClusterId | Long | The ID of the OceanBase cluster generated by the OceanBase Database system. |
| clusterId | Long | The ID of the OceanBase cluster generated by the OCP system. |
| clusterType | String | The type of the cluster. Valid values: |
| mode | String | The compatibility mode of the tenant. Valid values: |
| createTime | DateTime | The creation time. |
| primaryZone | String | The priorities of the zones. |
| zoneList | String | The list of zones. |
| locality | String | The replica distribution. |
| status | String | The status of the tenant. |
| locked | Boolean | Indicates whether the tenant was locked. |
| readonly | String | Indicates whether the tenant was read-only. |
| obVersion | String | The version of the OceanBase cluster. |
| description | String | The description of the tenant. |
Examples
Sample request
POST /api/v2/ob/clusters/1/tenants
body:
{
"name": "foo",
"mode": "MYSQL",
"primaryZone": "zone1,zone2;zone2",
"charset": "utf8mb4",
"collation": "utf8mb4_general_ci",
"description": "bar",
"whitelist": "%",
"rootPassword": "xxxxx",
"saveToCredential": true,
"zones": [
{
"name": "zone1",
"replicaType": "FULL",
"resourcePool": {
"unitSpecName": "S1",
"unitCount": 1
}
},
{
"name": "zone2",
"replicaType": "FULL",
"resourcePool": {
"unitSpecName": "S1",
"unitCount": 1
}
},
{
"name": "zone3",
"replicaType": "FULL",
"resourcePool": {
"unitSpecName": "S1",
"unitCount": 1
}
}
]
}
Sample response
{
"data": {
"clusterId": 4,
"clusterName": "protoss",
"clusterType": "PRIMARY",
"createTime": "2020-12-15T18:29:29.355+08:00",
"id": 6,
"locality": "FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3",
"locked": false,
"mode": "MYSQL",
"name": "foo",
"obClusterId": 51,
"obVersion": "2.2.60",
"primaryZone": "zone1,zone2;zone3",
"readonly": false,
"status": "CREATING",
"zoneList": "zone1;zone2;zone3"
},
"duration": 2949,
"server": "xxx.xxx.xxx.xxx",
"status": 200,
"successful": true,
"timestamp": "2020-12-15T18:29:29.496+08:00",
"traceId": "4d3cdd7bf53046e4"
}