Purpose
OceanBase Database manages physical resources based on resource units. You can execute the CREATE RESOURCE UNIT statement in the sys tenant to create a resource unit and specify a unit config for it. The unit config of a resource unit defines the common physical resources, such as the CPU, memory, log disk, and input/output operations per second (IOPS) resources.
The unit config of a resource unit defines the total amount of resources that can be allocated on a single OBServer node in a zone. A tenant can store data on a node only if it has a resource unit on this node.
The total amount of resources allocated to a tenant is calculated as follows: Unit config × Unit quantity.
Limitations and considerations
The unit config of a resource unit cannot exceed the total available resources of a single node.
Required privileges
You can create a resource unit only as the root user of the sys tenant ( namely root@sys).
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,]
[LOG_DISK_SIZE [=] 'size_value'];
Parameters
| Parameter | Description |
|---|---|
| IF NOT EXISTS | Optional. If the resource unit to be created already exists and IF NOT EXISTS is not specified, the system returns an error. |
| unit_name | The name of the resource unit. |
| MEMORY_SIZE | The memory size. The minimum value is controlled by the hidden parameter __min_full_resource_pool_memory, and is 5G by default. To ensure system stability, we recommend that you set the minimum memory size to 4G.
NoticeOceanBase Database does not support memory overcommitment since V4.0.0.0. |
| MAX_CPU | The maximum number of CPU cores. The minimum value is 1, which indicates one CPU core. |
| MIN_CPU | Optional. The minimum number of CPU cores. The minimum value is 1, which indicates one CPU core. If you do not specify this parameter, the default value is equal to the MAX_CPU value.
NoticeThe sum of the |
| MAX_IOPS | Optional. The maximum IOPS. The minimum value is 1024. The specified value must be greater than or equal to the value of MIN_IOPS. If you do not specify this parameter, the system automatically calculates the value of MAX_IOPS based on the following rules:
|
| MIN_IOPS | Optional. The minimum IOPS. The minimum value is 1024. If you do not specify this parameter, the system automatically calculates the value of MIN_IOPS based on the following rules:
|
| IOPS_WEIGHT | Optional. The IOPS weight. If you do not specify this parameter, the system automatically calculates the value of IOPS_WEIGHT based on the following rules:
|
| LOG_DISK_SIZE | Optional. The size of the log disk of the tenant. By default, if you do not specify this parameter, the log disk size is three times the memory size. The minimum value is 2G. |
Examples
Create a resource unit named unit1 and specify its unit config as follows: 4 CPU cores, 5 GB of memory, 10 GB of log disk space, a maximum IOPS of 1280, a minimum IOPS of 1024, and an IOPS weight of 1.
obclient [oceanbase]> CREATE RESOURCE UNIT unit1 MAX_CPU 4, MEMORY_SIZE '5G', MAX_IOPS 1280,LOG_DISK_SIZE '10G', MIN_IOPS=1024, IOPS_WEIGHT=1;
After the resource unit is created, you can execute the following statement to check the creation result:
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 | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
+----------------+-------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
| 1002 | unit1 | 2023-10-30 16:33:41.182430 | 2023-10-30 16:33:41.182430 | 4 | 4 | 5368709120 | 10737418240 | 1280 | 1024 | 1 |
+----------------+-------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+