Purpose
OceanBase Database manages physical resources by using units. The sys tenant can create units and specify the resource specifications of the units by using the CREATE RESOURCE UNIT statement. The resource specifications of a unit define the total amount of common physical resources, including CPU, memory, log disk storage space, IOPS, and so on.
The resource specifications of a unit define the total amount of resources that can be allocated to a single OBServer node within a single zone. A tenant can use the resources of a node only when it has a unit on that node.
The total amount of resources allocated to a tenant is equal to the unit specification multiplied by the number of units.
Limitations and considerations
The resource specifications of a unit cannot exceed the total amount of resources that can be allocated to a single node.
Privilege requirements
Only the root user of the sys tenant (root@sys) can create units. Other tenants are not supported to create units.
Syntax
CREATE RESOURCE UNIT [IF NOT EXISTS] unit_name
MEMORY_SIZE [=] 'size_value',
MAX_CPU [=] cpu_num,
[MAX_IOPS [=] iops_num,]
[MIN_CPU [=] cpu_num,]
[MIN_IOPS [=] iops_num,]
[IOPS_WEIGHT [=]iopsweight,]
[MAX_NET_BANDWIDTH [=] bandwidth_num,]
[NET_BANDWIDTH_WEIGHT [=] bandwidth_weight_num,]
[DATA_DISK_SIZE [=] 'size_value',]
[LOG_DISK_SIZE [=] 'size_value'];
Parameters
| Parameter | Description |
|---|---|
| IF NOT EXISTS | Optional. If the specified unit already exists and you do not specify IF NOT EXISTS, an error is returned. |
| unit_name | The name of the unit. |
| MEMORY_SIZE | The size of the memory. The minimum value is specified by the hidden parameter __min_full_resource_pool_memory, which defaults to 5 G. To ensure system stability, we recommend that you set the minimum value to 4 G.
NoticeMemory overcommit is not supported in OceanBase Database V4.0.0.0 and later. |
| MAX_CPU | The maximum number of CPU cores. The minimum value is 1. |
| MIN_CPU | The minimum number of CPU cores. The minimum value is 1. This parameter is optional. If you do not specify this parameter, the value of MAX_CPU is used as the default value.
NoticeThe sum of the |
| MAX_IOPS | The maximum IOPS. The minimum value is 1024. The value of MAX_IOPS must be greater than or equal to the value of MIN_IOPS. This parameter is optional. If you do not specify this parameter, the system automatically calculates the value of MAX_IOPS based on the following rules:
|
| MIN_IOPS | The minimum IOPS. The minimum value is 1024. This parameter is optional. If you do not specify this parameter, the system automatically calculates the value of MIN_IOPS based on the following rules:
|
| IOPS_WEIGHT | The weight of IOPS. This parameter is optional. If you do not specify this parameter, the system automatically calculates the value of IOPS_WEIGHT based on the following rules:
|
| MAX_NET_BANDWIDTH | The maximum network bandwidth that each unit of the tenant can use. The minimum value is 1 M. If you do not specify this parameter, the default value is INT64_MAX. |
| NET_BANDWIDTH_WEIGHT | The weight of the network bandwidth of the tenant unit. This parameter is used to calculate the proportion of the bandwidth of each OBServer node allocated to each tenant. The minimum value is 0. If you do not specify this parameter, the system automatically calculates the value of NET_BANDWIDTH_WEIGHT based on the following rules:
|
| DATA_DISK_SIZE | The size of the local disk space that each unit of the tenant can use. This parameter is applicable only in Shared-Storage (SS) mode. If you specify this parameter in Shared-Nothing (SN) mode, an error is returned. When you specify this parameter:
NoteIn SS mode, when you create a tenant, migrate a unit, or scale out the system, the system considers the |
| LOG_DISK_SIZE | The size of the log disk space of the tenant. This parameter is optional. If you do not specify this parameter, the default value is three times the memory size, with a minimum value of 2 G. |
Examples
Create a unit named
unit1with 4 CPU cores, 5G memory, 10G log disk space, IOPS limits of 1280 and 1024, and an IOPS weight of 1. Each unit can use up to 5M of network bandwidth with a weight of 10.obclient(root@sys)[(none)]> CREATE RESOURCE UNIT unit1 MAX_CPU 4, MEMORY_SIZE '5G', MAX_IOPS 1280, MIN_IOPS=1024, IOPS_WEIGHT=1, MAX_NET_BANDWIDTH '5M',NET_BANDWIDTH_WEIGHT 10, LOG_DISK_SIZE '10G';After the unit is created, you can confirm the result by querying the view. The statement is as follows:
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE NAME='unit1';The query result is as follows:
+----------------+-------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+----------+----------+-------------+-------------------+----------------------+ | UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | DATA_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | MAX_NET_BANDWIDTH | NET_BANDWIDTH_WEIGHT | +----------------+-------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+----------+----------+-------------+-------------------+----------------------+ | 1001 | unit1 | 2025-05-28 11:19:39.116490 | 2025-05-28 11:19:39.116490 | 4 | 4 | 5368709120 | 10737418240 | NULL | 1280 | 1024 | 1 | 5242880 | 10 | +----------------+-------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+----------+----------+-------------+-------------------+----------------------+ 1 row in setIn SS mode, create a unit named
unit1with 4 CPU cores, 5G memory, and 100G of local disk space per unit.obclient(root@sys)[(none)]> CREATE RESOURCE UNIT unit1 MAX_CPU 4, MEMORY_SIZE '5G', DATA_DISK_SIZE '100G';
