To horizontally scale resources in 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 resource 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 a tenant, you can adjust the value of the
UNIT_NUMparameter for all resource pools of the tenant 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, resource units with the same group ID (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 shows 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');
- 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.
- Adjust the UNIT_NUM parameter of resource pools assigned to a tenant.
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
Example 1:
Create a resource pool and increase the value of the
UNIT_NUMparameter for the resource pool before it is assigned to a tenant.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');Execute the following statement to increase the value of the
UNIT_NUMparameter for a single resource pool:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 3;Example 2:
Increase the value of the
UNIT_NUMparameter for a resource pool that has been assigned to a tenant in scenarios where you want to scale out your tenant.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 service capabilities of the tenant.You can execute the following statement to change the number of resource units in resource pool
r_p0to3to upgrade the service capability of the tenant:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;
Decrease the value of the UNIT_NUM parameter
Example 1:
Create a resource pool and decrease the value of the
UNIT_NUMparameter for the resource pool before it is assigned to a tenant.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');Execute the following statement to decrease the value of the
UNIT_NUMparameter for a single resource pool:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1;Example 2:
Decrease the value of the
UNIT_NUMparameter for a resource pool that has been assigned to a tenant in scenarios where you want to scale in your tenant.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 adjusts, it no longer needs two resource units in each zone. Therefore, it is necessary to consider decreasing the value ofUNIT_NUMto meet new business requirements.You can execute the following statement to change the number of resource units in resource pool
r_p0to1to downgrade the service capability of the tenant:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1;Alternatively, you can decrease the value of
UNIT_NUMby deleting a specifiedUNIT_GROUP.obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1 DELETE UNIT_GROUP =(1001);