Tenant scaling aims to improve or reduce the service capabilities of the tenant, including the computing and storage capacities. To meet this purpose, you can improve the service capabilities of a single node or add service nodes. This topic describes how to modify the unit number to increase or decrease service nodes to improve or reduce the overall service capabilities of a tenant, thereby implementing tenant scaling.
You can increase or decrease the unit number.
Background information
In the current version, OceanBase AI Database supports homogeneous and heterogeneous zone modes for tenants:
In the homogeneous zone mode, all zones of a tenant must have the same number of units. To facilitate unit management, the system introduces the unit group mechanism. Units in different zones can be classified into the same unit group. The units in a single unit group share the same unit group ID. Increasing or decreasing the number of units is to create or delete units based on unit groups.
In the heterogeneous zone mode, the
UNIT_NUMvalues of different zones can be the same or different. However, a tenant can have at most two differentUNIT_NUMvalues. Log streams are no longer bound to unit groups. Replicas in different zones are no longer required to be symmetric. For a tenant in the heterogeneous zone mode, you can increase or decrease the number of units of a resource pool in addition to increasing or decreasing the number of units of the tenant. This way, you can scale in or out a resource pool.
Notice
By default, existing tenants or tenants upgraded from earlier versions are in the homogeneous zone mode. To enable the heterogeneous zone mode, you must set the tenant-level parameter zone_deploy_mode to hetero. After you modify this parameter, you cannot change it back to homo.
Prerequisites
Before you perform a scale-in or scale-out operation on a tenant, you must perform the following steps:
Enable load balancing for the tenant.
The load balancing strategy for a tenant is jointly controlled by the tenant-level parameters
enable_rebalanceandenable_transfer.You can specify the
enable_rebalanceparameter in thesystenant to control whether to enable load balancing among tenants, and specify this parameter in a user tenant to control whether to enable load balancing for the current tenant. When you scale in or out a tenant, you must enable load balancing for the tenant. The default value istrue. The setting takes effect immediately without the need to restart the OBServer node.You can specify the
enable_transferparameter to control whether to enable the transfer feature for a tenant. The default value istrue. The setting takes effect immediately without the need to restart the OBServer node. Specifically:If the value of
enable_rebalanceisfalse, the system does not perform automatic load balancing regardless of whether the value ofenable_transferistrueorfalse.If the value of
enable_rebalanceistrueand the value ofenable_transferistrue, the system automatically adjusts partition distribution to achieve load balancing during a tenant scaling operation.If the value of
enable_rebalanceistrueand the value ofenable_transferisfalse, the system cannot initiate transfer operations during tenant scaling, but can implement limited load balancing through log stream migration.
You can enable load balancing for a tenant in the following ways:
Enable load balancing for a specified tenant from the
systenantEnable load balancing and the transfer feature for a specified tenant from the
systenantALTER SYSTEM SET enable_rebalance = true TENANT = 'tenant_name';ALTER SYSTEM SET enable_transfer = true TENANT = 'tenant_name';These statements only set the values of the
enable_rebalanceandenable_transferparameters totruefor the specified user tenant.Enable intra-tenant load balancing and the transfer feature for all user tenants from the
systenantALTER SYSTEM SET enable_rebalance = true TENANT = all_user;ALTER SYSTEM SET enable_transfer = true TENANT = all_user;or
ALTER SYSTEM SET enable_rebalance = true TENANT = all;ALTER SYSTEM SET enable_transfer = true TENANT = all;These statements only set the values of the
enable_rebalanceandenable_transferparameters totruefor all user tenants.Note
TENANT = all_userandTENANT = allhave the same semantics. If you want an operation to take effect on all user tenants, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated in the future.
Enable load balancing for a user tenant from the current tenant
You can execute the following statements to enable load balancing and the transfer feature for the current tenant:
ALTER SYSTEM SET enable_rebalance = true;ALTER SYSTEM SET enable_transfer = true;
For more information about the
enable_rebalanceandenable_transferparameters, see enable_rebalance and enable_transfer.If the tenant is deleted, drop the resource pool of the tenant to release resources. Resources in an idle resource pool are also considered occupied resources.
For more information about how to drop a resource pool, see Drop a resource pool.
Before you scale in a tenant, we recommend that you perform a minor compaction to release the memory in use by the tenant.
For more information about how to manually initiate a minor compaction, see Manually trigger a minor compaction.
Plan resources for the tenant to achieve the expected result.
For more information about resource planning for tenant scaling, see Resource planning for tenant scaling.
Considerations
When you scale in or out a tenant by adjusting the unit number, note the following considerations:
Do not modify the locality of the tenant during scaling in or out.
Do not expand the
ZONE_LISTof the resource pool of the tenant during scaling in or out.Do not add a new resource pool to the tenant during scaling in or out.
Do not merge resource pools during scaling in or out.
Do not migrate a unit in the
DELETINGstate during scaling in or out.
Increase the unit number
Increase the unit number for all resource pools of a tenant
For a tenant in the homogeneous zone mode or the heterogeneous zone mode, you can use the ALTER RESOURCE TENANT statement to increase the unit number for all resource pools of the tenant. The following example describes how to increase the unit number for all resource pools of the mysql001 tenant.
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> use oceanbase;View the information about the
mysql001tenant to obtain itsTENANT_ID.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, PRIMARY_ZONE, LOCALITY, TENANT_ROLE, UNIT_NUM, ZONE_UNIT_NUM_LIST FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mysql001';The query result is as follows:
+-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | PRIMARY_ZONE | LOCALITY | TENANT_ROLE | UNIT_NUM | ZONE_UNIT_NUM_LIST | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | 1006 | mysql001 | USER | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | PRIMARY | 1 | zone1:1,zone2:1,zone3:1 | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ 1 row in setIn the query result, the
TENANT_IDof the tenant is 1006, and the value ofUNIT_NUMis 1:1:1, indicating that the tenant has one unit in each zone.View the units owned by the
mysql001tenant.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1013 | 1006 | ACTIVE | 1002 | 1023 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1023 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1023 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 3 rows in setAccording to the query result, the
mysql001tenant has one unit in each zone, and these three units correspond to the sameUNIT_GROUP_ID.Change the value of
UNIT_NUMto 2 for themysql001tenant.obclient(root@sys)[oceanbase]> ALTER RESOURCE TENANT mysql001 UNIT_NUM = 2;After the command is executed, view the status of the current units.
obclient> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1013 | 1006 | ACTIVE | 1002 | 1024 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1024 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1024 | zone3 | 1001 | | 1025 | 1006 | ADDING | 1001 | 1025 | zone1 | 1001 | | 1026 | 1006 | ADDING | 1002 | 1025 | zone2 | 1001 | | 1027 | 1006 | ADDING | 1003 | 1025 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 6 rows in setYou can see that the new units are in the
ADDINGstate. After internal balancing is completed, the unit state changes fromADDINGtoACTIVE.Notice
- In OceanBase AI Database,
UNIT_NUMscaling is an asynchronous process, and the pending units are in theADDINGstate. - Rollback operations are supported during the scaling process (when the pending units are still in the
ADDINGstate).For example, in this scenario, you can execute the
ALTER RESOURCE TENANT mysql001 UNIT_NUM = 1;statement to revertUNIT_NUMto its original value. During rollback, the originalADDINGunits directly transition to theDELETINGstate. Note that when performing a rollback, you cannot specify a UNIT_GROUP to delete; the system automatically selectsADDINGunits for deletion. - Before the scaling process ends, only rollback operations are allowed; modifying
UNIT_NUMto other values is prohibited.
- In OceanBase AI Database,
View the execution status of the job for increasing the unit number.
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 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ | 26 | ALTER_RESOURCE_TENANT_UNIT_NUM | SUCCESS | 0 | 100 | 2025-06-18 10:10:19.430962 | 2025-06-18 10:10:54.229794 | 1006 | ALTER RESOURCE TENANT mysql001 UNIT_NUM = 2 | new unit num: '2' | 6.xx.xxx.xxx | 29700 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ 1 row in setIn the query result, find the corresponding job record based on the following fields:
START_TIME: the time when the job was initiated.SQL_TEXT: the SQL statement corresponding to the job.EXTRA_INFO: the number of units before and after the change.
If the value of
JOB_STATUSin the corresponding change record isSUCCESS, the job for increasing the unit number is successfully executed.For more information about the fields in the
DBA_OB_TENANT_JOBSview, see DBA_OB_TENANT_JOBS.View the units of the
mysql001tenant after the modification.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1013 | 1006 | ACTIVE | 1002 | 1024 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1024 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1024 | zone3 | 1001 | | 1025 | 1006 | ACTIVE | 1001 | 1025 | zone1 | 1001 | | 1026 | 1006 | ACTIVE | 1002 | 1025 | zone2 | 1001 | | 1027 | 1006 | ACTIVE | 1003 | 1025 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 6 rows in set
The query result shows that the number of units in each zone is changed from 1 to 2 for the mysql001 tenant. The tenant has one unit in each zone before the change, and two units in each zone after the change, thereby achieving tenant scaling out.
Increase the unit number for a single resource pool of a tenant
For a tenant in the heterogeneous zone mode, if the tenant has multiple resource pools, you can also use the ALTER RESOURCE POOL statement to increase the unit number of a specified resource pool. This method is not supported for tenants in the homogeneous zone mode.
The following example describes how to increase the unit number of the pool2 resource pool of the mysql001 tenant.
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> use oceanbase;View the information about the
mysql001tenant to obtain itsTENANT_ID.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, PRIMARY_ZONE, LOCALITY, TENANT_ROLE, UNIT_NUM, ZONE_UNIT_NUM_LIST FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mysql001';The query result is as follows:
+-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | PRIMARY_ZONE | LOCALITY | TENANT_ROLE | UNIT_NUM | ZONE_UNIT_NUM_LIST | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | 1006 | mysql001 | USER | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | PRIMARY | 2 | zone1:2,zone2:2,zone3:2 | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ 1 row in setIn the query result, the
TENANT_IDof the tenant is 1006, and the number of units in each zone is 2:2:2.View the resource configuration of the current tenant.
obclient(root@sys)[oceanbase]> SELECT c.TENANT_ID, e.TENANT_NAME, concat(c.NAME, ': ', d.NAME) `pool:conf`,c.ZONE_LIST, concat(c.UNIT_COUNT, ' unit: ', d.min_cpu, 'C/', ROUND(d.MEMORY_SIZE/1024/1024/1024,0), "G") unit_info FROM oceanbase.DBA_OB_RESOURCE_POOLS c, oceanbase.DBA_OB_UNIT_CONFIGS d, oceanbase.DBA_OB_TENANTS e WHERE c.UNIT_CONFIG_ID=d.UNIT_CONFIG_ID AND c.TENANT_ID=e.TENANT_ID AND c.TENANT_ID=1006;The query result is as follows:
+-----------+-------------+------------------+-----------+---------------+ | TENANT_ID | TENANT_NAME | pool:conf | ZONE_LIST | unit_info | +-----------+-------------+------------------+-----------+---------------+ | 1006 | mysql001 | pool3: test_unit | zone3 | 2 unit: 1C/8G | | 1006 | mysql001 | pool2: test_unit | zone2 | 2 unit: 1C/8G | | 1006 | mysql001 | pool1: test_unit | zone1 | 2 unit: 1C/8G | +-----------+-------------+------------------+-----------+---------------+ 3 rows in setThe query result shows that the
mysql001tenant has three resource pools namedpool1,pool2, andpool3, which are located inzone1,zone2, andzone3, respectively.Change the
UNIT_NUMof thepool2resource pool of themysql001tenant to 3 based on your actual requirements.obclient(root@sys)[oceanbase]> ALTER RESOURCE POOL pool2 UNIT_NUM = 3;View the status of the current units.
obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1013 | 1006 | ACTIVE | 1002 | 1026 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1024 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1024 | zone3 | 1001 | | 1025 | 1006 | ACTIVE | 1001 | 1025 | zone1 | 1001 | | 1026 | 1006 | ACTIVE | 1002 | 1027 | zone2 | 1001 | | 1027 | 1006 | ACTIVE | 1003 | 1025 | zone3 | 1001 | | 1028 | 1006 | ADDING | 1002 | 1028 | zone2 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 7 rows in setYou can see that the new unit is in the
ADDINGstate. After internal load balancing is completed, the unit state changes fromADDINGtoACTIVE.Note
- In OceanBase AI Database,
UNIT_NUMscaling-out is an asynchronous process, and the new units are in theADDINGstate. - Rollback operations are supported during the scaling-out process (when the new units are still in the
ADDINGstate).For example, in this scenario, you can execute the
ALTER RESOURCE POOL pool2 UNIT_NUM = 2;statement to revert theUNIT_NUMvalue to its original state. During rollback, the original units in theADDINGstate directly transition to theDELETINGstate. Note that when performing a rollback, you cannot specify which units to delete; the system automatically selects units in theADDINGstate for deletion. - Before the scaling-out process is complete, only rollback operations are allowed; modifying
UNIT_NUMto other values is prohibited.
- In OceanBase AI Database,
View the execution status of the job for increasing the unit number.
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 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ | 27 | ALTER_RESOURCE_TENANT_UNIT_NUM | INPROGRESS | NULL | 0 | 2025-06-18 11:02:52.005261 | 2025-06-18 11:02:52.005261 | 1006 | ALTER RESOURCE POOL pool2 UNIT_NUM = 3 | new unit num: '3' | 6.xx.xxx.xxx | 29700 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ 1 row in setIn the query result, find the corresponding job record based on the following fields:
START_TIME: the time when the job was initiated.SQL_TEXT: the SQL statement corresponding to the job.EXTRA_INFO: the number of units before and after the change.
If the value of
JOB_STATUSin the corresponding change record isSUCCESS, the job for increasing the unit number is successfully executed.For more information about the fields in the
DBA_OB_TENANT_JOBSview, see DBA_OB_TENANT_JOBS.View the units of the
mysql001tenant after the modification.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1013 | 1006 | ACTIVE | 1002 | 1026 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1024 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1024 | zone3 | 1001 | | 1025 | 1006 | ACTIVE | 1001 | 1025 | zone1 | 1001 | | 1026 | 1006 | ACTIVE | 1002 | 1027 | zone2 | 1001 | | 1027 | 1006 | ACTIVE | 1003 | 1025 | zone3 | 1001 | | 1028 | 1006 | ADDING | 1002 | 1028 | zone2 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 7 rows in set
The query result shows that the number of units in the pool2 resource pool of the mysql001 tenant is changed from 2 to 3. Before the change, the number of units in each zone was 2. After the change, the number of units in zone1 and zone3 is still 2, and the number of units in zone2 is changed to 3. The tenant is scaled out.
Reduce the unit number
Considerations
Before you reduce the unit number of a tenant, make sure whether GTS exclusive mode is enabled. The tenant-level parameter enable_gts_standalone specifies whether to enable GTS exclusive mode. The default value is False, which indicates that the feature is disabled.
If GTS exclusive mode is enabled, note the following considerations:
After GTS exclusive mode is enabled, the
UNIT_NUMof each zone of the tenant must be greater than or equal to 2. If you reduce theUNIT_NUMof any zone to a value less than 2, an error is returned.When you reduce the unit number by deleting a specified unit list or unit group, you cannot delete a unit or unit group exclusive to GTS. Otherwise, an error is returned.
Reduce the unit number for all resource pools of a tenant
For a tenant in the homogeneous zone mode or the heterogeneous zone mode, you can use the ALTER RESOURCE TENANT statement to decrease the unit number for all resource pools of the tenant. The following example describes how to decrease the unit number for all resource pools of the mysql001 tenant.
The following example describes how to decrease the unit number of the mysql001 tenant.
Log in to the
systenant of the cluster as therootuser.obclient -h172.xxx.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> use oceanbase;View the information about the
mysql001tenant to obtain itsTENANT_ID.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, PRIMARY_ZONE, LOCALITY, TENANT_ROLE, UNIT_NUM, ZONE_UNIT_NUM_LIST FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mysql001';The query result is as follows:
+-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | PRIMARY_ZONE | LOCALITY | TENANT_ROLE | UNIT_NUM | ZONE_UNIT_NUM_LIST | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | 1006 | mysql001 | USER | zone1;zone2,zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | PRIMARY | 3 | zone1:3,zone2:3,zone3:3 | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ 1 row in setIn the query result, the
TENANT_IDof the tenant is 1006, and the value ofUNIT_NUMis3, indicating that the tenant has three units in each zone.View the units of the
mysql001tenant.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1001 | 1006 | ACTIVE | 1001 | 1018 | zone1 | 1001 | | 1005 | 1006 | ACTIVE | 1003 | 1018 | zone3 | 1001 | | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1007 | 1006 | ACTIVE | 1002 | 1018 | zone2 | 1001 | | 1011 | 1006 | ACTIVE | 1002 | 1019 | zone2 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1020 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+-------+----------------+ 9 rows in setThe query result shows that the
mysql001tenant has three units in each zone. The units with the IDs1001,1005, and1007belong to the unit group with the ID1018. The units with the IDs1006,1011, and1012belong to the unit group with the ID1019. The units with the IDs1013,1014, and1015belong to the unit group with the ID1020.Change the value of
UNIT_NUMto 2 for themysql001tenant.Randomly delete a unit to reduce the unit number
For a tenant in the homogeneous zone mode or the heterogeneous zone mode, you can execute the following statement to reduce the unit number.
obclient(root@sys)[oceanbase]> ALTER RESOURCE TENANT mysql001 UNIT_NUM = 2;After this statement is executed:
For a tenant in the homogeneous zone mode, such as the
mysql001tenant in this example, where theUNIT_NUMof all resource pools is changed from 3 to 2, the system randomly specifies a unit group with the sameUNIT_GROUP_IDfor deletion.For a tenant in the heterogeneous zone mode, the system randomly selects a unit group for deletion.
Delete a specified unit group to reduce the unit number
For a tenant in the homogeneous zone mode, you can also execute the following statement to reduce the unit number. This statement is not supported for a tenant in the heterogeneous zone mode.
obclient(root@sys)[oceanbase]> ALTER RESOURCE TENANT mysql001 UNIT_NUM = 2 DELETE UNIT_GROUP =(1018);After this statement is executed, for a scenario where each zone has three units, the system redistributes the data in the specified unit group to other unit groups, and then deletes the unit group.
View the status of the current units after the statement is executed.
obclient> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+----------+------------------+---------------+-------+----------------+ | 1001 | 1006 | DELETING | 1001 | 1018 | zone1 | 1001 | | 1005 | 1006 | DELETING | 1003 | 1018 | zone3 | 1001 | | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1007 | 1006 | DELETING | 1002 | 1018 | zone2 | 1001 | | 1011 | 1006 | ACTIVE | 1002 | 1019 | zone2 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1020 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+----------+------------------+---------------+-------+----------------+ 9 rows in setThe unit to be deleted is in the
DELETINGstate.Note
- In OceanBase AI Database, reducing the
UNIT_NUMis an asynchronous process. During the scale-down process (while the unit to be deleted is still in theDELETINGstate), rollback operations are supported.For example, in this example, you can execute the
ALTER RESOURCE TENANT mysql001 UNIT_NUM = 3;statement to change theUNIT_NUMback to its original value. When rolling back, the original units in theDELETINGstate will directly transition to theADDINGstate. - During the scale-down process, only rollback operations are supported. Modifying the
UNIT_NUMto other values is prohibited.
- In OceanBase AI Database, reducing the
View the execution status of the job for decreasing the unit number.
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 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ | 25 | ALTER_RESOURCE_TENANT_UNIT_NUM | SUCCESS | 0 | 100 | 2025-06-18 10:06:15.648806 | 2025-06-18 10:08:39.969346 | 1006 | alter resource tenant mysql001 unit_num=2 | new unit num: '2' | 6.xx.xxx.xxx | 29700 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ 1 row in setIn the query result, find the corresponding job record based on the following fields:
START_TIME: the time when the job was initiated.SQL_TEXT: the SQL statement corresponding to the job.EXTRA_INFO: the number of units before and after the change.
If the value of
JOB_STATUSin the corresponding job record isSUCCESS, the job for decreasing the unit number is successfully executed.For more information about the fields in the
DBA_OB_TENANT_JOBSview, see DBA_OB_TENANT_JOBS.View the units of the
mysql001tenant after the modification.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1011 | 1006 | ACTIVE | 1002 | 1019 | zone2 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1020 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+------+-----------------+ 6 rows in set
The query result shows that the number of units in each zone is changed from 3 to 2 for the mysql001 tenant. The tenant has three units in each zone before the change, and two units in each zone after the change. The tenant is scaled in.
Reduce the unit number of a single resource pool for a tenant
For a tenant in the heterogeneous zone mode, you can use the ALTER RESOURCE POOL statement to decrease the unit number of a resource pool for the tenant. You cannot use this statement for a tenant in the homogeneous zone mode.
The following example shows how to decrease the unit number of the pool2 resource pool of the mysql001 tenant.
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> use oceanbase;View the information about the
mysql001tenant to obtain itsTENANT_ID.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, PRIMARY_ZONE, LOCALITY, TENANT_ROLE, UNIT_NUM, ZONE_UNIT_NUM_LIST FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mysql001';The query result is as follows:
+-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | PRIMARY_ZONE | LOCALITY | TENANT_ROLE | UNIT_NUM | ZONE_UNIT_NUM_LIST | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ | 1006 | mysql001 | USER | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | PRIMARY | 2 | zone1:2,zone2:2,zone3:2 | +-----------+-------------+-------------+--------------------+---------------------------------------------+-------------+----------+-------------------------+ 1 row in setIn the query result, the
TENANT_IDof the tenant is 1006, and the number of units in each zone is 2:2:2.View the resource configuration of the current tenant.
obclient(root@sys)[oceanbase]> SELECT c.TENANT_ID, e.TENANT_NAME, concat(c.NAME, ': ', d.NAME) `pool:conf`,c.ZONE_LIST, concat(c.UNIT_COUNT, ' unit: ', d.min_cpu, 'C/', ROUND(d.MEMORY_SIZE/1024/1024/1024,0), "G") unit_info FROM oceanbase.DBA_OB_RESOURCE_POOLS c, oceanbase.DBA_OB_UNIT_CONFIGS d, oceanbase.DBA_OB_TENANTS e WHERE c.UNIT_CONFIG_ID=d.UNIT_CONFIG_ID AND c.TENANT_ID=e.TENANT_ID AND c.TENANT_ID=1006;The query result is as follows:
+-----------+-------------+------------------+-----------+---------------+ | TENANT_ID | TENANT_NAME | pool:conf | ZONE_LIST | unit_info | +-----------+-------------+------------------+-----------+---------------+ | 1006 | mysql001 | pool3: test_unit | zone3 | 2 unit: 1C/8G | | 1006 | mysql001 | pool2: test_unit | zone2 | 2 unit: 1C/8G | | 1006 | mysql001 | pool1: test_unit | zone1 | 2 unit: 1C/8G | +-----------+-------------+------------------+-----------+---------------+ 3 rows in setThe query result shows that the
mysql001tenant has three resource pools namedpool1,pool2, andpool3, which are located inzone1,zone2, andzone3, respectively.View the units of the
mysql001tenant.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+--------+------------------+---------------+-------+----------------+ | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1011 | 1006 | ACTIVE | 1002 | 1019 | zone2 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1020 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+--------+------------------+---------------+------+-----------------+ 6 rows in setChange the
UNIT_NUMof thepool2resource pool of themysql001tenant to 1 based on your actual requirements.Randomly delete a unit to reduce the unit number
obclient(root@sys)[oceanbase]> ALTER RESOURCE POOL pool2 UNIT_NUM = 1;Delete specified units to reduce the unit number.
obclient(root@sys)[oceanbase]> ALTER RESOURCE POOL pool2 UNIT_NUM = 1 DELETE UNIT=(1011);
View the status of the current units after the command is executed.
obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+----------+------------------+---------------+-------+----------------+ | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1011 | 1006 | DELETING | 1002 | 1019 | zone2 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1020 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+----------+------------------+---------------+------+-----------------+ 6 rows in setThe unit to be deleted is in the
DELETINGstate.Notice
- In OceanBase AI Database, scaling down the
UNIT_NUMis an asynchronous process. During the scaling-down process (while the unit to be deleted is still in theDELETINGstate), rollback operations are supported.For example, in this example, you can execute the
ALTER RESOURCE POOL pool2 UNIT_NUM = 2;statement to change theUNIT_NUMback to its original value. When rolling back, the original units in theDELETINGstate will directly transition to theADDINGstate. - During the scaling-down process, only rollback operations are supported. Modifying the
UNIT_NUMto other values is prohibited.
- In OceanBase AI Database, scaling down the
View the execution status of the job for reducing the unit number.
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 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ | 24 | ALTER_RESOURCE_TENANT_UNIT_NUM | SUCCESS | 0 | 100 | 2025-06-18 09:39:34.319331 | 2025-06-18 09:40:30.439822 | 1006 | alter resource pool pool2 unit_num=1 | new unit num: '1' | 6.xx.xxx.xxx | 29700 | +--------+--------------------------------+------------+-------------+----------+----------------------------+----------------------------+-----------+-----------------------------------------------------------+-------------------+--------------+-------------+ 1 row in setIn the query result, find the corresponding job record based on the following fields:
START_TIME: the time when the job was initiated.SQL_TEXT: the SQL statement corresponding to the job.EXTRA_INFO: the number of units before and after the change.
If the value of
JOB_STATUSin the corresponding change record isSUCCESS, the job for decreasing the unit number is successfully executed.For more information about the fields in the
DBA_OB_TENANT_JOBSview, see DBA_OB_TENANT_JOBS.View the units of the
mysql001tenant after the modification.obclient(root@sys)[oceanbase]> SELECT UNIT_ID, TENANT_ID, STATUS, RESOURCE_POOL_ID, UNIT_GROUP_ID, ZONE, UNIT_CONFIG_ID 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 | UNIT_CONFIG_ID | +---------+-----------+----------+------------------+---------------+-------+----------------+ | 1006 | 1006 | ACTIVE | 1003 | 1019 | zone3 | 1001 | | 1012 | 1006 | ACTIVE | 1001 | 1019 | zone1 | 1001 | | 1013 | 1006 | ACTIVE | 1002 | 1021 | zone2 | 1001 | | 1014 | 1006 | ACTIVE | 1001 | 1020 | zone1 | 1001 | | 1015 | 1006 | ACTIVE | 1003 | 1020 | zone3 | 1001 | +---------+-----------+----------+------------------+---------------+------+-----------------+ 5 rows in set
The query result shows that the number of units in the pool2 resource pool of the mysql001 tenant is changed from 2 to 1. Before the change, the number of units in each zone is 2. After the change, the number of units in zone1 and zone3 is still 2, but the number of units in zone2 is changed to 1. The tenant is scaled in.