You can scale out or scale in tenant resources by adjusting the UNIT_NUM parameter of resource pools. This allows you to dynamically change the number of units available to the tenant in each zone, thereby increasing or decreasing the tenant's service capacity in the corresponding zone.
OceanBase Database supports both homogeneous and heterogeneous zone modes for tenants:
In homogeneous zone mode, all zones of the tenant must have the same
UNIT_NUM.In heterogeneous zone mode, the
UNIT_NUMcan vary across zones, but a tenant can have at most two differentUNIT_NUMvalues across all zones.
Notice
By default, existing tenants or those upgraded to the current version are in homogeneous zone mode. To enable heterogeneous zone mode, you need to set the tenant-level parameter zone_deploy_mode to hetero. Once changed, it cannot be reverted to homo.
Changing the UNIT_NUM parameter can be categorized into two types: increasing and decreasing the value.
For tenants in homogeneous zone mode:
If the resource pool is not granted to the tenant, you can independently increase or decrease the
UNIT_NUMof the resource pool.If the resource pool is granted to the tenant, you can only adjust the
UNIT_NUMof all granted resource pools simultaneously, not individually.
For tenants in heterogeneous zone mode, you can adjust the
UNIT_NUMof resource pools whether or not they are granted to the tenant. This means you can either adjust theUNIT_NUMof all granted resource pools simultaneously or independently adjust theUNIT_NUMof individual resource pools.
Increasing or decreasing the UNIT_NUM essentially involves adding or removing units. Here are some example statements for adjusting the UNIT_NUM of a resource pool:
For a resource pool in heterogeneous zone mode, or for an ungranted resource pool in homogeneous zone mode, you can independently adjust the
UNIT_NUMof the resource pool.Assume the following resource pool information:
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');Here are some adjustment examples:
obclient> ALTER RESOURCE POOL rp1 UNIT_NUM 3; // Increase UNIT_NUMobclient> ALTER RESOURCE POOL rp1 UNIT_NUM 2; // Decrease UNIT_NUMobclient> ALTER RESOURCE POOL rp1 UNIT_NUM 1 DELETE UNIT = (1001, 1003); // Specify units to decrease UNIT_NUMAdjust the
UNIT_NUMof all resource pools for the tenant simultaneously.Assume the following resource pool information for the 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');Here are some adjustment examples:
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3; // Increase UNIT_NUM for both resource poolsobclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1; // Decrease UNIT_NUM for both resource pools
Increase UNIT_NUM
Example 1: Increase UNIT_NUM for a single resource pool
After you create a resource pool, you can increase the
UNIT_NUMof a single resource pool.Assume that the information of the resource pool to be adjusted is as follows:
obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');For a resource pool in a heterogeneous zone mode or a resource pool not granted to a tenant in a homogeneous zone mode, you can increase the
UNIT_NUMof the resource pool by using the following statement:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 3;Example 2: Increase UNIT_NUM for a tenant
Usually, you increase the
UNIT_NUMof a tenant when you scale out the tenant. For example, for a resource pool granted to a 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 the preceding example, the tenant
ttuses the resource poolr_p0. Each zone (zone1,zone2, andzone3) has 2 units. As the business volume increases, the 2 units in each zone cannot meet the business requirements. Therefore, you need to increase theUNIT_NUMto improve the service capability of the tenant to meet the new business requirements.You can execute the following statement to increase the number of units of the tenant in the resource pool
r_p0to3to improve the service capability of the tenant.obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;
Decrease UNIT_NUM
Example 1: Decrease UNIT_NUM for a single resource pool
After you create a resource pool, you can decrease the
UNIT_NUMof a single resource pool. Assume that the information of the resource pool to be adjusted is as follows.obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');For a resource pool in a heterogeneous zone mode or a resource pool not granted to a tenant in a homogeneous zone mode, you can decrease the
UNIT_NUMof the resource pool by using the following statement:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1;You can also decrease the
UNIT_NUMof a single resource pool by deleting specified units. The statement is as follows:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1 DELETE UNIT=(1001,1002,1003);Example 2: Decrease UNIT_NUM for a tenant
Usually, you decrease the
UNIT_NUMof a tenant when you scale in the tenant. For example, for a resource pool granted to a 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 the preceding example, the tenant
ttuses the resource poolr_p0. Each zone (zone1,zone2, andzone3) has 2 units. As the business requirements change, the 2 units in each zone are no longer needed. Therefore, you need to decrease theUNIT_NUMto meet the new business requirements.You can execute the following statement to decrease the number of units of the tenant in the resource pool
r_p0to1to reduce the service capability of the tenant.obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1;In a homogeneous zone mode, you can also decrease the
UNIT_NUMby deleting specifiedUNIT_GROUP.obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1 DELETE UNIT_GROUP =(1001);
