Purpose
OceanBase Database manages physical resources by using resource units. The sys tenant can create resource units and specify the resource specifications of the units by using the CREATE RESOURCE UNIT statement. The resource specifications of a resource unit define the common physical resources, including CPU, memory, log disk storage space, and IOPS.
The resource specifications of a resource unit define the total amount of resources that can be allocated to a single OBServer node in a single zone. Only when a tenant has a resource unit on a node can it use the resources on that node to store data.
The total amount of resources allocated to a tenant is calculated as: Unit specification × Number of units.
Limitations and considerations
The resource specifications of a resource 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 resource units. Other tenants cannot create resource 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,]
[LOG_DISK_SIZE [=] 'size_value'];
Parameters
| Parameter | Description |
|---|---|
| IF NOT EXISTS | Optional. If the resource unit to be created already exists and you do not specify IF NOT EXISTS, an error is returned. |
| unit_name | The name of the resource unit. |
| MEMORY_SIZE | The memory specification. The minimum value is controlled by the hidden parameter __min_full_resource_pool_memory, which defaults to 5 GB. To ensure system stability, we recommend that you set the minimum memory specification to 4 GB.
NoticeStarting from OceanBase Database V4.0.0.0, memory overcommit is no longer supported. |
| MAX_CPU | The maximum number of CPU cores. The minimum value is 1, which indicates 1 core. |
| MIN_CPU | The minimum number of CPU cores. The minimum value is 1, which indicates 1 core. This parameter is optional. If you do not specify this parameter, its value is the same as that of MAX_CPU.
NoticeThe sum of the |
| MAX_IOPS | The maximum IOPS. The minimum value is 1024. The value of this parameter must be greater than or equal to that 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 can be used by each resource unit of the tenant. The minimum value is 1 M. If you do not specify this parameter, the default value is INT64_MAX. |
| NET_BANDWIDTH_WEIGHT | The network bandwidth weight of the tenant's resource unit. This parameter is used to calculate the proportion of bandwidth allocated to each tenant by each OBServer node. 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:
|
| LOG_DISK_SIZE | The size of the log disk space for the tenant. This parameter is optional. If you do not specify this parameter, the default value is three times the memory specification, with a minimum of 2 GB. |
Examples
Create a resource unit named unit1 with the following specifications: 4 CPU cores; 5 GB of memory; 10 GB of log disk space; IOPS upper limit of 1280, IOPS lower limit of 1024, and IOPS weight of 1; each unit can use up to 5 MB of network bandwidth with a weight of 10.
obclient [oceanbase]> 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 resource unit is created, you can query the view to confirm the creation result. The statement is as follows:
obclient [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 set