Purpose
After a resource pool is allocated to a tenant, you can use the ALTER RESOURCE TENANT statement to modify the UNIT_NUM parameter in the resource pool's configuration.
To modify other attributes of a resource pool, use the ALTER RESOURCE POOL statement. For more information about this statement, see ALTER RESOURCE POOL.
Limitations and considerations
The
ALTER RESOURCE TENANTstatement modifies the number of resource units for all resource pools under a tenant.Before using the
ALTER RESOURCE TENANTstatement to perform tenant scaling, you must set a load balancing strategy for the tenant. Otherwise, scaling may fail. For detailed operations and descriptions on setting a load balancing strategy for a tenant, see [Implement tenant scaling by adjusting unit numbers](../../../../600.manage/200.tenant-management/600.common-tenant-operations/800.tenant-scale-in-and-out/300.adjust-unit-number.md).
Privilege requirements
Only the root user of the sys tenant (root@sys) can modify the resource pool configuration of a tenant. Other tenants do not support modifying their own resource pool configurations.
Syntax
ALTER RESOURCE TENANT tenant_name UNIT_NUM [=] unit_num [ DELETE UNIT_GROUP = ( unit_group_id_list ) ];
Parameters
Parameters |
Description |
|---|---|
| tenant_name | The name of the tenant for which you want to modify the resource pool configuration. |
| unit_num | Modify the number of resource units for all resource pools in a tenant. Add UNIT_NUM, its value must be less than or equal to the number of nodes in the target zone. |
| unit_group_id_list | Only applicable to scale-down scenarios in homogeneous zone mode. When you decrease unit_num, you can use DELETE UNIT_GROUP to drop a specified unit group. If DELETE UNIT_GROUP is not specified, the system randomly deletes the specified number of unit groups. |
Examples
Change the number of resource units for all resource pools under tenant
tenant1to 3.obclient(root@sys)[oceanbase]> ALTER RESOURCE TENANT tenant1 UNIT_NUM = 3;In a homogeneous zone mode scale-down scenario, delete the unit group with
UNIT_GROUP_IDequal to1006under tenanttenant2.Run the following commands in sequence to enable load balancing.
obclient(root@sys)[oceanbase]> ALTER SYSTEM SET enable_rebalance = true TENANT = 'tenant2';obclient(root@sys)[oceanbase]> ALTER SYSTEM SET enable_transfer = true TENANT = 'tenant2';Obtain the tenant's
TENANT_ID.obclient(root@sys)[oceanbase]> SELECT TENANT_ID,TENANT_NAME,TENANT_TYPE FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'tenant2';The query result is as follows:
+-----------+-------------+-------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | +-----------+-------------+-------------+ | 1006 | tenant2 | USER | +-----------+-------------+-------------+ 1 row in setView the units owned by the tenant and obtain the
UNIT_GROUP_IDof the unit to be deleted.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, SVR_IP, SVR_PORT FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1006;The query result is as follows:
+---------+-----------+--------+------------------+---------------+-------+----------------+----------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | ZONE | SVR_IP | SVR_PORT | +---------+-----------+--------+------------------+---------------+-------+----------------+----------+ | 1016 | 1006 | ACTIVE | 1003 | 1006 | zone1 | xxx.xx.xxx.194 | 2882 | | 1017 | 1006 | ACTIVE | 1003 | 1007 | zone1 | xxx.xx.xxx.198 | 2882 | | 1018 | 1006 | ACTIVE | 1003 | 1006 | zone2 | xxx.xx.xxx.192 | 2882 | | 1019 | 1006 | ACTIVE | 1003 | 1007 | zone2 | xxx.xx.xxx.196 | 2882 | | 1020 | 1006 | ACTIVE | 1003 | 1006 | zone3 | xxx.xx.xxx.204 | 2882 | | 1021 | 1006 | ACTIVE | 1003 | 1007 | zone3 | xxx.xx.xxx.197 | 2882 | +---------+-----------+--------+------------------+---------------+-------+----------------+----------+ 6 rows in setPerform the scale-down operation based on the obtained
UNIT_GROUP_ID.obclient(root@sys)[oceanbase]> ALTER RESOURCE TENANT tenant2 UNIT_NUM = 1 DELETE UNIT_GROUP = (1006);After the task is successfully executed, you can view its execution status in the
DBA_OB_TENANT_JOBSview.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_TENANT_JOBS WHERE JOB_TYPE='ALTER_RESOURCE_TENANT_UNIT_NUM' AND TENANT_ID=1006;The query result is as follows:
+--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------------------+--------------------+----------------+-------------+ | JOB_ID | JOB_TYPE | JOB_STATUS | RESULT_CODE | PROGRESS | START_TIME | MODIFY_TIME | TENANT_ID | SQL_TEXT | EXTRA_INFO | RS_SVR_IP | RS_SVR_PORT | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------------------+--------------------+----------------+-------------+ | 6 | ALTER_RESOURCE_TENANT_UNIT_NUM | SUCCESS | 0 | 100 | 2023-09-25 18:01:30.069506 | 2023-09-25 18:01:45.068740 | 1006 | ALTER RESOURCE TENANT tenant2 UNIT_NUM = 2 | FROM: '1', TO: '2' | xxx.xx.xxx.196 | 2882 | | 7 | ALTER_RESOURCE_TENANT_UNIT_NUM | SUCCESS | 0 | 100 | 2023-09-26 09:37:32.367076 | 2023-09-26 09:39:05.651200 | 1006 | ALTER RESOURCE TENANT tenant2 UNIT_NUM = 1 DELETE UNIT_GROUP = (1006) | FROM: '2', TO: '1' | xxx.xx.xxx.196 | 2882 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------------------+--------------------+----------------+-------------+ 2 rows in set
References
Achieve tenant scaling by adjusting the unit number