Overview
Call CreateTenants to create a tenant in the specified OceanBase Cloud instance. Specify the tenant name, resource specifications, character set, and time zone.
Note
To create a tenant of the specified resource specification, the cluster must have sufficient available resources.
API details
Constraints
The caller must have an AccessKey for accessing the multi-cloud API. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
POST /api/v2/instances/{instanceId}/tenants
Request parameters
Path
Name |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| instanceId | String | Yes | The ID of the OceanBase Cloud instance. | ob317v4uif**** |
Query
Name |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| requestId | String | Yes | The ID of the request. This parameter is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
Body
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| tenantName | String | Yes | The name of the tenant. The name is case-insensitive. | pay_**** |
| tenantId | String | No | The ID of the tenant. | t33h8y08k**** |
| tenantMode | String | Yes | The mode of the tenant. Valid values: Oracle and MySQL. If the database version is V4.2.1.8, V4.2.5, or V4.3.3, the tenant can only use the HBase API or the Table API. | Oracle |
| primaryZone | String | Yes | The primary zone of the tenant. The zone must be a zone in the cluster. | ap-southeast-1a |
| charset | String | Yes | The character set.
Notice
|
utf8mb4 |
| collation | String | No | The collation. | utf8mb4_general_ci |
| description | String | No | The description of the database. | this is a test database |
| whitelist | String | No | The IP address whitelist of the tenant. | 192.168.1.0/24,10.0.0.1 |
| timeZone | String | Yes | The time zone of the tenant. For more information, see DescribeTimeZones. | Asia/Singapore |
| cpu | Integer | Yes | The number of CPU cores of the tenant. | 2 |
| memory | Integer | Yes | The size of the memory of the tenant, in GiB. | 10 |
| diskSize | Integer | No | The size of the disk of the tenant, in GiB. | 100 |
| unitNum | Integer | No | The number of resource distribution nodes of the tenant. This parameter is related to the deployment mode of the cluster. For example, if the deployment mode of the cluster is 2-2-2, the maximum number of resource distribution nodes is 2. | 2 |
| environment | String | No | The environment of the tenant. | production |
| enablePublicLink | Boolean | No | Specifies whether to create a public address when creating the tenant. Valid values:
|
true |
| parameterTemplate | String | No | The parameter template. | default_template |
| createParams | object | No | The parameters for creating the tenant. This parameter specifies whether to make the table names case-sensitive. The value is a HashMap. Example: createParams":{"lower_case_table_names":"1"} |
{"lower_case_table_names":"1"} |
| tenantCompatibilityModeEnum | String | No | The compatibility mode of the tenant. | MYSQL |
| proxyAddressMasterZone | String | No | The primary zone of the proxy. | ap-southeast-1a |
| proxySetting | Object | No | Database proxy configuration for the tenant.
|
See the proxySetting request example. |
proxySetting object fields
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| mode | String | Yes | Database proxy specification type. Valid values:
|
k8s_shared |
| deploymentArchitecture | String | Yes | Database proxy deployment architecture. Valid values:
NoteThree-zone deployment is available in supported Alibaba Cloud and AWS regions. Both three-zone architectures require a dedicated proxy cluster with the 2.0 architecture and an OceanBase instance deployed across three zones. |
single_az_deployment |
| zone | Array[String] | Yes | Physical zone IDs for the primary nodes. Specify at least one zone available to the target instance or tenant. The number of zones depends on deploymentArchitecture. |
See the zone request example. |
| slaveZone | Array[String] | Yes | Physical zone IDs for the standby nodes. Specify standby zones for an active-standby deployment. For other architectures, specify []. This field does not accept null. |
See the slaveZone request example. |
| nodeCpu | Number | Yes | CPU cores per proxy node. The value must be greater than 0. Creating or resizing a shared or Serverless proxy requires at least 1 core per node. | 1 |
Response parameters
Name |
Type |
Description |
Example value |
|---|---|---|---|
| data | object | The information about the tenant. | |
| tenantId | String | The ID of the tenant. | t33h8y08k**** |
Examples
Request example
Create a MySQL tenant and a public address on an Alibaba Cloud instance. The account and region support shared proxies.
curl --request POST 'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants?requestId={requestId}' \
--digest -u '<AccessKey ID>:<AccessKey Secret>' \
-H 'X-Ob-Project-Id: <Project ID>' \
-H 'Content-Type: application/json' \
--data '{
"tenantName": "pay_test",
"tenantMode": "MySQL",
"primaryZone": "ap-southeast-1a",
"charset": "utf8mb4",
"timeZone": "Asia/Singapore",
"cpu": 2,
"memory": 10,
"unitNum": 1,
"enablePublicLink": true,
"proxySetting": {
"mode": "k8s_shared",
"deploymentArchitecture": "single_az_deployment",
"zone": [
"ap-southeast-1a"
],
"slaveZone": [],
"nodeCpu": 1
}
}'
Note
- A project ID uniquely identifies a project. For information about how to obtain the project ID of an instance, see Manage projects.
- Make sure that the project ID corresponding to the specified instanceId is consistent with the specified project ID.
Response example
JSON format
{
"success": true,
"data": {
"tenantId": "t33h8y08k****"
},
"requestId": "dc302d76-66b5-48d8-ab53-a035********",
"server": "xxx.xxx.x.xxx:xxxx"
}