Purpose
OceanBase Database manages physical resources through resource units. The sys tenant can use the CREATE RESOURCE UNIT statement to create resource units and specify their resource specifications. Resource specifications define common physical resources, including CPU, memory, log disk storage space, IOPS, etc.
Resource specifications define the total amount of resources that can be allocated to a single OBServer node within a single zone. A tenant can only use the resources on a node if it has a resource unit on that node.
The total amount of resources allocated to a tenant is calculated as: Unit specification × Number of resource units.
Limitations and considerations
The resource specifications of a resource unit cannot exceed the total allocatable resources of a single node.
Privilege requirements
Only the root user of the sys tenant (root@sys) can create resource units. Other tenants do not support creating 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,]
[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. The default value is 5 GB. To ensure system stability, we recommend that you set the minimum memory size 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, 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 this parameter 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 available to each 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 weight of the network bandwidth of the tenant unit. This parameter is used to calculate the bandwidth allocated to each tenant on 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:
|
| DATA_DISK_SIZE | The size of the local disk space available to each unit of the tenant. This parameter is applicable only to the Shared-Storage (SS) mode. If you specify this parameter in the Shared-Nothing (SN) mode, an error is returned. When you specify this parameter:
NoteIn the 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, and the minimum value is 2 GB. |
Examples
Create a unit named
unit1with 4 CPU cores, 5 GB of memory, 10 GB of log disk space, IOPS between 1024 and 1280, and a weight of 1. Each unit can use up to 5 MB 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 query the view to verify the result. 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 the SS mode, create a unit named
unit1with 4 CPU cores, 5 GB of memory, and 100 GB of local disk space.obclient(root@sys)[(none)]> CREATE RESOURCE UNIT unit1 MAX_CPU 4, MEMORY_SIZE '5G', DATA_DISK_SIZE '100G';