Horizontal management of tenant resources is mainly achieved by dynamically adjusting the available resources of a tenant through modifying the UNIT_NUM of a resource pool. Specifically, you can adjust the UNIT_NUM of a resource pool to change the number of units in each zone under the resource pool, thereby increasing or decreasing the service capacity of the tenant in the corresponding zone.
OceanBase Database supports two zone deployment modes: homogeneous zone mode and heterogeneous zone mode:
In homogeneous zone mode, the
UNIT_NUMmust be the same for all zones under a tenant.In heterogeneous zone mode, the
UNIT_NUMcan be the same or different across zones under a tenant, but a tenant can have at most two differentUNIT_NUMvalues across all its zones.
Notice
By default, existing tenants and upgraded tenants use homogeneous zone mode. To enable heterogeneous zone mode, you must set the tenant-level parameter zone_deploy_mode to hetero. After the change, you cannot switch back to homo (homogeneous zone mode).
Changes to UNIT_NUM fall into two categories: increasing UNIT_NUM and decreasing UNIT_NUM:
For tenants deployed in homogeneous zone mode:
If a resource pool is not assigned to a tenant, you can increase or decrease the
UNIT_NUMof that resource pool individually.If a resource pool is already assigned to a tenant, you can only adjust the
UNIT_NUMof all assigned resource pools simultaneously; individual adjustment is not supported.
For tenants deployed in heterogeneous zone mode, you can adjust the
UNIT_NUMregardless of whether the resource pool is assigned to a tenant. That is, you can either adjust theUNIT_NUMof all assigned resource pools simultaneously or increase or decrease theUNIT_NUMof a single resource pool individually.
Increasing or decreasing UNIT_NUM essentially means adding or removing units. The following examples show how to adjust the UNIT_NUM of a resource pool:
For a resource pool in heterogeneous zone mode, or for an unassigned resource pool in homogeneous zone mode, adjust the
UNIT_NUMof the resource pool individually.Assume the resource pool to be adjusted is created as follows:
obclient> CREATE RESOURCE POOL rp1 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2');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); // Decrease UNIT_NUM by deleting specified resource unitsAdjust the UNIT_NUM of all resource pools of a tenant simultaneously.
Assume the tenant's resource pools are created as follows:
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');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 for increasing
UNIT_NUM:After you create a resource pool, you can increase the
UNIT_NUMof a single resource pool individually.Assume the resource pool to be adjusted is created as follows:
obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');For a resource pool in heterogeneous zone mode, or for an unassigned resource pool in homogeneous zone mode, use the following statement to increase the
UNIT_NUMof the resource pool:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 3;Example 2 for increasing
UNIT_NUM:Increasing
UNIT_NUMtypically occurs in tenant scale-out scenarios. For example, for a resource pool that is already assigned 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 this example, tenant
ttuses resource poolr_p0. Each ofzone1,zone2, andzone3has 2 units. As the business volume grows, 2 units per zone can no longer support the current workload. Therefore, you need to increaseUNIT_NUMto improve the service capacity of the tenant to meet the new business requirements.You can use the following statement to change the number of units in resource pool
r_p0to3for the tenant, thereby improving the tenant's service capacity:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;
Decrease UNIT_NUM
Example 1 for decreasing
UNIT_NUM:After you create a resource pool, you can decrease the
UNIT_NUMof a single resource pool individually. Assume the resource pool to be adjusted is created as follows:obclient> CREATE RESOURCE POOL r_p0 UNIT 'uc1', UNIT_NUM 2, ZONE_LIST ('zone1', 'zone2', 'zone3');For a resource pool in heterogeneous zone mode, or for an unassigned resource pool in homogeneous zone mode, use the following statement to decrease the
UNIT_NUMof the resource pool:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1;You can also decrease the
UNIT_NUMof a single resource pool by deleting specified units. Use the following statement:obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 1 DELETE UNIT=(1001,1002,1003);Example 2 for decreasing
UNIT_NUM:Decreasing
UNIT_NUMtypically occurs in tenant scale-in scenarios. For example, for a resource pool that is already assigned 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 this example, tenant
ttuses resource poolr_p0. Each ofzone1,zone2, andzone3has 2 units. As the business adjusts, 2 units per zone are no longer needed. Therefore, you need to decreaseUNIT_NUMto meet the new business requirements.You can use the following statement to change the number of units in resource pool
r_p0to1for the tenant, thereby reducing the tenant's service capacity:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1;Alternatively, in homogeneous zone mode, you can also decrease
UNIT_NUMby deleting a specifiedUNIT_GROUP:obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 1 DELETE UNIT_GROUP =(1001);