To vertically scale resources in a tenant, you can adjust the unit config of the resource pools assigned to the tenant to adjust the service capability of the tenant. To adjust the unit config of a resource pool, you can either modify or switch the unit config.
Modify the unit config
You can modify the unit config, that is, directly modify the CPU and memory resource configurations in the unit config, of a resource pool to adjust the service capability of the tenant to which the resource pool is assigned.
Assume that resource pools pool1 and pool2 are created, and both of them use the unit config uc1. You can adjust uc1 by modifying the maximum CPU and memory size of the resource pools. Specifically, set MAX_CPU to 6 and MEMORY_SIZE to 36G, and leave other options unchanged. The sample statement is as follows:
obclient> CREATE RESOURCE UNIT uc1 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G';
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';
You can modify resource parameters to adjust the unit config of the resource pool for a tenant in the corresponding zone, so as to adjust the service capability of the tenant.
Switch the unit config
You can switch the unit config of each resource unit in a resource pool to adjust the service capability of the tenant to which the resource pool is assigned.
Assume that the resource pool rp1 originally uses the unit config uc1. You can switch the unit config of the resource pool rp1 from uc1 to uc2. The sample statement is as follows:
obclient> ALTER RESOURCE POOL rp1 UNIT 'uc2';
Examples and limitations
Generally, you can either modify or switch the unit config to adjust the service capability of a tenant. This is equivalent to modifying the specifications of resource units used for the tenant. When you modify the unit config, you can either upgrade or downgrade the unit config.
Upgrade the unit config
Unit config upgrade mainly applies to resource scale-up in a tenant. You can respectively scale up CPU and memory resources.
Here are some examples:
Example 1
Create a unit config named
u_c0and a resource pool namedpool1, and then applyu_c0topool1.obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3');Increase the values of the
MIN_CPU,MAX_CPU, andMEMORY_SIZEparameters inu_c0.obclient> ALTER RESOURCE UNIT u_c0 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G';The adjustment is intended to upgrade the unit config of
pool1and thereby enhance the service capability of the corresponding tenant.
Example 2
Create two unit configs named
u_c0andu_c1and a resource pool namedpool1, and then applyu_c0topool1.obclient> CREATE RESOURCE UNIT u_c0 MAX_CPU 5, MIN_CPU 4, MEMORY_SIZE '36G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '108G'; obclient> CREATE RESOURCE UNIT u_c1 MAX_CPU 10, MIN_CPU 8, MEMORY_SIZE '72G', MAX_IOPS 10000, MIN_IOPS 10000, LOG_DISK_SIZE = '216G'; obclient> CREATE RESOURCE POOL pool1 unit='u_c0', unit_num=3, zone_list=('z1','z2','z3');Switch the unit config of
pool1tou_c1.obclient> ALTER RESOURCE POOL pool1 unit='u_c1';The adjustment is intended to upgrade the unit config of
pool1and thereby enhance the service capability of the corresponding tenant.
Regardless of whether you modify or switch the unit config, the total resources after the adjustment must meet the following requirements:
Sum(min_cpu) <= CPU_CAPACITY;
Sum(memory_size) <= MEM_CAPACITY;
Sum(max_cpu) <= CPU_CAPACITY * resource_hard_limit;
Otherwise, the system returns an error, indicating that the operation fails.
Downgrade the unit config
OceanBase Database also allows you to downgrade the unit config of a resource pool while ensuring sufficient server resources. When you decrease the value of the MEMORY_SIZE parameter, note that: The MEM_USED parameter indicates the actual memory usage of a tenant on an OBServer node, so make sure that the new value of the MEMORY_SIZE parameter for each OBServer node that serves the tenant is greater than or equal to the value of the MEM_USED parameter. Otherwise, the adjustment fails. If this is the case, you must perform a minor compaction to release the memory, and then attempt to downgrade the unit config of the resource pool again.