To achieve horizontal scaling of resources under a tenant, you can modify the UNIT_NUM parameter of a resource pool for the tenant to dynamically adjust the available resources of the tenant. Specifically, you can adjust the UNIT_NUM parameter of a resource pool to modify the number of resource units in each zone for the resource pool, so as to increase or decrease the service capacity of the tenant in each zone. In OceanBase Database V4.0 and later, the number of units must be the same for all resource pools of a tenant.
You can increase or decrease the value of the UNIT_NUM parameter.
For a resource pool that is not assigned to any tenant, you can increase or decrease the value of the
UNIT_NUMparameter.For resource pools that are assigned to tenants, you can adjust the value of the
UNIT_NUMparameter for these resource pools simultaneously, but it is not possible to modify the parameter value for an individual resource pool.
Starting from V4.0.0, OceanBase Database requires that the number of units within each Zone of a tenant must be consistent. To facilitate unified management of units across different zones, the system introduced the unit group mechanism. Essentially, units with the same number (UNIT_GROUP_ID) across different zones belong to the same unit group. Increasing or decreasing UNIT_NUM fundamentally involves creating and deleting units by unit group.
The following example show how to modify the UNIT_NUM parameter of a resource pool:
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
1. Adjust the UNIT_NUM parameter of a resource pool not assigned to a tenant.
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.
2. Adjust the value of the UNIT_NUM parameter of resource pools assigned to tenants.
obclient> CREATE RESOURCE POOL rp2 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');
obclient> CREATE RESOURCE POOL rp3 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone3');
obclient> CREATE TENANT tt RESOURCE_POOL_LIST = ('rp2', 'rp3') ...;
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3; // Increase the value of the UNIT_NUM parameter for two resource pools.
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1; // Decrease the value of the UNIT_NUM parameter for two resource pools.
Increase the value of the UNIT_NUM parameter
The following examples show how to increase the value of the UNIT_NUM parameter.
Example 1: After you create a resource pool, adjust the value of the
UNIT_NUMparameter for it before it is assigned to a tenant.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');To increase the value of
UNIT_NUMfor a single resource pool, use the following statement:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 3;Example 2: Increase the value of the
UNIT_NUMparameter in scenarios where you want to scale out your tenants.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');obclient> CREATE TENANT tt RESOURCE_POOL_LIST = ('r_p0');In this example, tenant
ttuses resource poolr_p0. Zoneszone1,zone2, andzone3have two resource units respectively. As the business volume grows, the deployment mode of two resource units in each zone cannot meet the business requirements. Therefore, you need to increase the value ofUNIT_NUMto improve the business capabilities of the tenant.You can execute the following statement to change the number of resource units in the resource pool
r_p0to3for the tenant:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;
Decrease the value of the UNIT_NUM parameter
Example 1: After you create a resource pool, adjust the value of the
UNIT_NUMparameter for it before it is assigned to a tenant.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');To decrease the value of
UNIT_NUMfor a single resource pool, use the following statement:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1;Example 2: Decrease the value of the
UNIT_NUMparameter in scenarios where you want to scale in your tenants.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');obclient> CREATE TENANT tt RESOURCE_POOL_LIST = ('r_p0');In the example, tenant
ttuses the resource poolr_p0. Zoneszone1,zone2, andzone3have two resource units respectively. As the business adjusts, it is no longer necessary to have 2 units in each zone. Therefore, it is necessary to consider reducing the value ofUNIT_NUMto meet the new business requirements.You can execute the following statement to change the number of resource units in the resource pool
r_p0to1for the tenant:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1;Alternatively, you can also reduce the value of
UNIT_NUMby deleting a specifiedUNIT_GROUP.obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1 DELETE UNIT_GROUP =(1001);