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, 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. To create a tenant, perform the following steps:
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 CPUs, 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. Sample statement for creating a resource unit configuration:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5,MIN_CPU 4, MAX_MEMORY '36G', MIN_MEMORY '32G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64;
Only the MIN_CPU, MAX_CPU, MIN_MEMORY, and MAX_MEMORY fields in the statement take effect. Other fields are required, but do not take effect. The MIN_CPU and MIN_MEMORY fields specify the minimum number of CPUs and the minimum size of memory that can be provided by a resource unit.
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. Sample statement for creating a resource pool:
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 fields to create a resource pool:
The
UNIT 'uc1'field 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.The
ZONE_LIST ('zone1','zone2')field specifies the application scope of the resource pool and specifies that you want to create the resource units in the resource pool inzone1andzone2.The
UNIT_NUM 2field specifies the number of resource units in the resource pool, indicating that two resource units are to be created in each zone specified by theZONE_LISTfield.
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:
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.
Change tenant resources
To change the resources of a tenant, you can modify one or more of the following fields: UNIT, ZONE_LIST, and UNIT_NUM. You can also perform the SPLIT and MERGE operations on resource pools to change tenant resources.
Modify a resource unit configuration
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:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MAX_MEMORY '36G', MIN_MEMORY '32G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64;
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, MIN_MEMORY '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, MIN_MEMORY '36G'; statement modifies the MAX_CPU parameter of uc1 to 6 and the MIN_MEMORY parameter to 36G. Other configurations remain unchanged. You can modify the parameters of the resource unit configuration to adjust the resource specifications of the resource pool for the tenant in the corresponding zone. This way, the service capabilities of the tenant are adjusted.
Change a new resource unit configuration
You can change 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.
Sample statement for changing a resource unit configuration:
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. OceanBase Database allows you to modify the MIN_CPU, MAX_CPU, MIN_MEMORY, and MAX_MEMORY parameters at the same time. If you want to adjust the service capabilities of a tenant, you can modify or change 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
If you want to scale out the CPU and memory of a tenant, you can increase the resource specifications.
Example 1:
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MAX_MEMORY '36G', MIN_MEMORY '32G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64; 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, MAX_MEMORY '72G', MIN_MEMORY '64G';In example 1, a resource unit configuration
u_c0and a resource poolpool1are created.pool1uses the resource unit configurationu_c0. Then, you can increase the value of theMIN_CPU,MAX_CPU,MIN_MEMORY, orMAX_MEMORYparameter ofu_c0. The adjustment is intended to increase the resource specifications ofpool1to improve the service capabilities of a tenant.Example 2:
obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MAX_MEMORY '36G', MIN_MEMORY '32G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64; obclient> CREATE RESOURCE UNIT u_c1 MAX_CPU 10, MIN_CPU 8, MAX_MEMORY '72G', MIN_MEMORY '64G', MAX_IOPS 128, MIN_IOPS 128, MAX_DISK_SIZE '2T', MAX_SESSION_NUM 64; 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 poolpool1are 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 ofpool1to improve the service capabilities of a tenant.Decrease resource specifications
You can decrease resource specifications in the same manner that you increase resource specifications.
Modify the UNIT_NUM parameter
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:
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 for specified resource units.
If 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 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:
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');
If you modify the ZONE_LIST parameter, you can specify a value to expand or narrow the application scope of the zones. The ALTER RESOURCE POOL pool1 ZONE_LIST=('z1','z2','z3','z4'); statement expands the scope of the 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:
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:
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');