OceanBase Database is a multi-tenant database system. A cluster can contain multiple tenants, and each tenant provides independent database services. OceanBase Database manages the available resources of tenants based on the following concepts: resource unit configuration (unit config), resource pool, and resource unit.
Create tenant resources
Before you create a tenant, you must specify the resource unit configuration and resource application scope of the tenant. The procedure for creating a tenant is as follows:
Create a resource unit configuration
Create a resource pool
Create a tenant
Create a resource unit configuration
The resource unit configuration describes the specifications of each resource unit in the resource pool, such as the available CPU cores, memory, storage space, and input/output operations per second (IOPS). You can modify the resource unit configuration to dynamically adjust the specifications of resource units. The resource unit configuration specifies the service capabilities rather than the real-time load of each resource unit. A sample statement for creating a resource unit configuration is as follows:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T' ;
Required parameters in the CREATE RESOURCE UNIT statement include the following ones:
MAX_CPU: the maximum CPU resources that can be provided by a resource unit that uses this resource unit configuration.MEMORY_SIZE: the memory size that can be provided by a resource unit that uses this resource unit configuration.
Take note of the following description about the optional parameters MIN_CPU, MAX_IOPS, MIN_IOPS, and LOG_DISK_SIZE:
MIN_CPU: the minimum CPU resources that can be provided by a resource unit that uses this resource unit configuration. This parameter defaults toMAX_CPU.MAX_IOPSandMIN_IOPS: the maximum and minimum IOPS resources that can be provided by a resource unit that uses this resource unit configuration. The minimum values of the two parameters are both 1024, and the value ofMAX_IOPSmust be greater than or equal to that ofMIN_IOPS.If the values of
MIN_IOPSandMAX_IOPSare not specified, the default value ofMIN_IOPSandMAX_IOPSisINT64_MAX.If only
MAX_IOPSis specified, theMIN_IOPSvalue is the same as theMAX_IOPSvalue. If onlyMIN_IOPSis specified, theMAX_IOPSvalue is the same as theMIN_IOPSvalue.
LOG_DISK_SIZE: the log disk space, which is three times the memory size by default, and is at least 2 GB.
Resource configuration of a meta tenant
A meta tenant is not configured with independent resource units. Tenant resource management does not involve the meta tenant. By default, the system reserves resources for the meta tenant when a user tenant is created. These resources are automatically deducted from the resources of the user tenant. The resources of a meta tenant, including CPU, MEMORY, IOPS, and LOG_DISK_SIZE, use default settings and cannot be specified by users.
The resources are described as follows:
CPU resources (CPU): A meta tenant shares CPU resources with the corresponding user tenant. The minimum specification available on ApsaraDB for OceanBase is 1C2G. Therefore, the minimum CPU specification is one core. The CPU resource specification of the meta tenant displayed in the
GV$OB_UNITSview isNULL, which indicates that the meta tenant share the CPU resources with the user tenant.Memory resources (MEMORY): Memory resource sharing is not allowed. Memory resources of the meta tenant are isolated from those of the user tenant. By default, the meta tenant occupies 10% of the overall tenant memory specification. To ensure the normal operation of the meta tenant, the meta tenant must have at least 512 MB of memory. The memory specification of the user tenant is the overall tenant memory specification minus the memory specification of the meta tenant. The minimum overall tenant memory specification is adjusted to 1 GB. Here are some examples:
If the overall tenant memory specification is greater than or equal to 10 GB, the ratio of the memory specification of the meta tenant to that of the user tenant is 1:9.
If the overall tenant memory specification is greater than or equal to 2 GB and less than 10 GB, the memory size of the meta tenant is fixed at 1 GB, and the remaining memory is allocated to the user tenant.
If the overall tenant memory specification is less than 2 GB, the memory size of the meta tenant is fixed at 512 MB, and the remaining memory is allocated to the user tenant.
The minimum overall tenant memory specification is 1 GB. In this case, the meta tenant and the user tenant each occupy 512 MB of memory.
Log disk resources (LOG_DISK_SIZE): You can leave the log disk resource specification unspecified. By default, the log disk size is three times the memory size. The minimum log disk size is 2 GB. Like memory resources, log disk resources cannot be shared between the meta tenant and the user tenant. By default, the meta tenant occupies 10% of the overall tenant disk space. To ensure the normal operation of the meta tenant, the meta tenant must have at least 512 MB of log disk space.
IOPS resources (IOPS): The meta tenant shares IOPS resources with the corresponding user tenant. The IOPS resource specification of the meta tenant displayed in the
GV$OB_UNITSview isNULL, which indicates that the meta tenant shares the IOPS resources with the user tenant.
The following table lists the resource specifications of a user tenant and a meta tenant.
| Resource parameter | Tenant specification | User tenant | Meta tenant |
|---|---|---|---|
| MIN_CPU/MAX_CPU | Minimum: 1 core | Shared CPU resource specifications | Shared CPU resource specifications |
| MEMORY_SIZE | Minimum: 1 GB | Minimum: 512 MB | 10% of the overall tenant memory specification
|
| LOG_DISK_SIZE | Minimum: 2 GB | Minimum: 1.5 GB | 10% of the overall tenant log disk, and 512 MB at the minimum |
| MAX_IOPS/MIN_IOPS | Minimum: 1024 | Shared IOPS resource specifications | Shared IOPS resource specifications |
Create a resource pool
A resource pool consists of multiple resource units. You can apply a resource unit configuration to a resource pool to specify physical resources for each resource unit in the resource pool. A sample statement for creating a resource pool is as follows:
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
The statement creates a resource pool named rp1. You must configure the following elements to create a resource pool:
UNIT 'uc1': specifies that the resource unit configuration of the resource pool isuc1. Each resource unit in the resource pool is configured based on the specifications ofuc1.ZONE_LIST ('zone1','zone2'): specifies the application scope of the resource pool and specifies that you want to create the resource units in the resource pool inzone1andzone2.UNIT_NUM 2: specifies the number of resource units in the resource pool, indicating that two resource units are to be created in each zone specified byZONE_LIST.
You must deploy each resource on a physical server that can accommodate the resource. A physical server can accommodate only one resource unit in the same resource pool. If zone1 or zone2 contains only one physical server or the resources on the physical server do not meet the specifications of uc1, the sample statement fails to create the resource pool.
Create a tenant
After you create the resource pool, you can create a tenant. A resource pool can belong to only one tenant, but a tenant can have one or more resource pools. A tenant can have only one resource pool in the same zone, which means that the zones of multiple resource pools that belong to the same tenant cannot overlap. The set of all resource units in all resource pools of a tenant describes all physical servers available for the tenant.
Sample statements for creating a tenant are as follows:
obclient> CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('z1', 'z2');
obclient>CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z3');
obclient>CREATE TENANT tt resource_pool_list=('pool1','pool2');
In the example, two resource pools pool1 and pool2 are created, and then the tenant tt is created. The tenant tt has two resource units in both z1 and z2 and one resource unit in z3. The specifications of each resource unit comply with the resource configuration specified by uc1.
Notice
The zones of different resource pools allocated to the same tenant must not overlap.
Change tenant resources
To change the resources of a tenant, you can modify one or more of the following elements: UNIT, ZONE_LIST, and UNIT_NUM. You can also perform the SPLIT and MERGE operations on resource pools to change tenant resources.
Modify resource configurations
You can modify the CPU or memory specifications of a resource unit configuration to adjust the resource specifications and service capabilities of a tenant in the resource pool. Sample statements for modifying a resource unit configuration are as follows:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '32G', MMAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T';
obclient> CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('z1', 'z2');
obclient> CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 1, ZONE_LIST ('z3');
obclient> CREATE TENANT tt resource_pool_list=('pool1','pool2');
obclient> ALTER RESOURCE UNIT uc1 MAX_CPU 6, MEMORY_SIZE '36G';
In the example, the resource unit configuration specified for the resource pools pool1 and pool2 is uc1. The ALTER RESOURCE UNIT uc1 MAX_CPU 6, MEMORY_SIZE '36G' statement changes the MAX_CPU value of uc1 to 6 and the MEMORY_SIZE value to 36G. Other configurations remain unchanged. You can modify the resource parameters to adjust the resource specifications of the resource pool for a tenant in the corresponding zone, so as to adjust the service capability of the tenant.
Switch resource unit configurations
You can switch the resource unit configuration of a resource pool to adjust the resource specifications of each resource unit in the resource pool. This way, the resource specifications and service capabilities of the tenant in the resource pool are adjusted.
A sample statement for switching the resource unit configuration of a resource pool is as follows:
obclient> ALTER RESOURCE POOL rp1 UNIT 'uc2';
In this example, the original resource unit configuration of the resource pool rp1 is uc1. The statement switches the resource unit configuration of rp1 from uc1 to uc2. Theoretically, OceanBase Database allows you to modify the values of MIN_CPU, MAX_CPU, and MEMORY_SIZE at the same time. If you want to adjust the service capabilities of a tenant, you can modify or switch the resource unit configuration. This is equivalent to modifying the specifications of resource units for the tenant. You can modify the specifications of a resource in the following scenarios:
Increase resource specifications
Increasing resource specifications is primarily used in tenant resource scaling scenarios, where you can increase the CPU and memory resources separately.
Example 1:
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3'); obclient> ALTER RESOURCE UNIT u_c0 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G';In example 1, resource unit configuration
u_c0and resource poolpool1are created. Resource poolpool1uses resource unit configurationu_c0. Then, you can increase the value ofMIN_CPU,MAX_CPU, orMEMORY_SIZEofu_c0. The adjustment is intended to increase the resource specifications ofpool1, to upgrade the service capability of the corresponding tenant.Example 2:
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MMAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T'; obclient> CREATE RESOURCE UNIT u_c1 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G', MMAX_IOPS 128000, MIN_IOPS 128000, LOG_DISK_SIZE '2T'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3'); obclient> ALTER RESOURCE POOL pool1 unit='u_c1';In example 2, two resource unit configurations
u_c0andu_c1and a resource pool namedpool1are created.pool1originally uses the resource unit configurationu_c0and then switches to the resource unit configurationu_c1. The adjustment is intended to increase the resource specifications ofpool1, to upgrade the service capability of the corresponding tenant.Decrease resource specifications
You can decrease resource specifications in the same manner that you increase resource specifications.
Modify UNIT_NUM for unallocated resource pools
You can modify the UNIT_NUM parameter of a resource pool to adjust the number of resource units in each zone of the resource pool. This allows you to upgrade or downgrade the service capabilities of the tenant in a specified zone.
Sample statements for modifying the UNIT_NUM parameter of a resource pool are as follows:
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
obclient> ALTER RESOURCE POOL rp1 UNIT_NUM 3; // Increase the value of the UNIT_NUM parameter.
obclient> ALTER RESOURCE POOL rp1 UNIT_NUM 2; // Decrease the value of the UNIT_NUM parameter.
obclient> ALTER RESOURCE POOL rp1 UNIT_NUM 1 DELETE UNIT = (1001, 1003); // Decrease the value of the UNIT_NUM parameter by deleting the specified resource units.
When you modify the UNIT_NUM parameter, you can increase the value of the UNIT_NUM parameter or decrease the value of the UNIT_NUM parameter. The ALTER RESOURCE POOL rp1 UNIT_NUM 3 statement increases the value of the UNIT_NUM parameter. The ALTER RESOURCE POOL rp1 UNIT_NUM 2 and ALTER RESOURCE POOL rp1 UNIT_NUM 1 DELETE UNIT = (1001, 1003) statements decrease the value of the UNIT_NUM parameter.
Modify UNIT_NUM for tenant resource pools
You can modify the UNIT_NUM parameter of a resource pool after it is assigned to a tenant. You can modify resource pools by tenant only. The modification of a resource pool succeeds only when all resource pools are modified. Sample statements for modifying the UNIT_NUM parameter of a tenant resource pool are as follows:
obclient> CREATE RESOURCE POOL pool1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
obclient> CREATE RESOURCE POOL pool2 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone3');
obclient> CREATE TENANT tt resource_pool_list=('pool1','pool2');
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;// Increase the value of UNIT_NUM.
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1;//Decrease the value of UNIT_NUM.
Modify the ZONE_LIST parameter
You can modify the ZONE_LIST parameter of a resource pool to adjust the scope of zones to which the resource pool applies. This allows you to adjust the scope of zones to which tenant data applies.
Sample statements for modifying the ZONE_LIST parameter of a resource pool are as follows:
obclient> CREATE RESOURCE POOL pool1 UNIT_NUM=3, UNIT='unit_config', ZONE_LIST=('z1','z2','z3');
obclient> CREATE RESOURCE POOL pool2 UNIT_NUM=3, UNIT='unit_config', ZONE_LIST=('z1','z2','z3');
obclient> ALTER RESOURCE POOL pool1 ZONE_LIST=('z1','z2','z3','z4');
obclient> ALTER RESOURCE POOL pool2 ZONE_LIST=('z1','z2');
When you modify the ZONE_LIST parameter, you can expand or narrow the scope of the zones. The ALTER RESOURCE POOL pool1 ZONE_LIST=('z1','z2','z3','z4') statement expands the scope of zones. The ALTER RESOURCE POOL pool2 ZONE_LIST=('z1','z2') statement narrows the scope of zones.
Split a resource pool
You can split a resource pool into multiple resource pools. Sample statements for splitting a resource pool are as follows:
obclient> CREATE RESOURCE POOL pool1 UNIT='uc0', UNIT_NUM=1, ZONE_LIST=('z1','z2','z3');
obclient> ALTER RESOURCE POOL pool1 SPLIT INTO ('pool10','pool11','pool12') ON ('z1','z2','z3');
obclient> ALTER RESOURCE POOL pool10 UNIT='uc1';
obclient> ALTER RESOURCE POOL pool11 UNIT='uc2';
obclient> ALTER RESOURCE POOL pool12 UNIT='uc3';
Merge resource pools
You can merge multiple resource pools into one resource pool. Sample statements for merging multiple resource pools are as follows:
obclient> CREATE RESOURCE POOL pool1 UNIT='uc0', UNIT_NUM=1, ZONE_LIST=('z1');
obclient> CREATE RESOURCE POOL pool2 UNIT='uc0', UNIT_NUM=1, ZONE_LIST=('z2');
obclient> CREATE RESOURCE POOL pool3 UNIT='uc0', UNIT_NUM=1, ZONE_LIST=('z3');
obclient> ALTER RESOURCE POOL MERGE ('pool1','pool2','pool3') INTO ('pool0');
Note
The resource pools can still be used by the tenant when they are being merged. They are merged into one resource pool only from the perspective of the management layer in which the RootService is located, to facilitate unified maintenance.