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. Moreover, in OceanBase Database V4.0, reducing the value of theUNIT_NUMparameter for resource pools is not supported.
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.
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, you can adjust the value of the UNIT_NUM parameter 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');
obclient> ALTER RESOURCE POOL r_p0 UNIT_NUM 3;
Example 2: You can increase the value of the UNIT_NUM parameter 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 tt uses resource pool r_p0. zone1, zone2, and zone3 have 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 of UNIT_NUM to 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_p0 to 3 for the tenant:
obclient> ALTER RESOURCE TENANT tt UNIT_NUM = 3;