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 number of resource units 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 number of resource units. OceanBase Database requires that all zones have the same number of resource units in V4.0.0 and later. To facilitate resource unit management, the system introduces the unit group mechanism. Resource units in different zones can be classified into the same unit group. The resource units in a single unit group share the same unit group ID. Increasing or decreasing the number of resource units is to create or delete resource units based on unit groups.
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 to achieve a balance among service nodes.
The tenant-level parameter
enable_rebalancespecifies whether to enable load balancing for a tenant. You can specify this parameter in the sys tenant 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. The default value istrue. The setting takes effect immediately without the need to restart the OBServer node.You can execute one of the following statements to enable load balancing for a tenant:
Enable load balancing for a specified tenant from the sys tenant
ALTER SYSTEM SET enable_rebalance = true TENANT = 'tenant_name';This statement only sets the value of the
enable_rebalanceparameter totruefor the specified user tenant.Here is an example:
ALTER SYSTEM SET enable_rebalance = true TENANT = 'oracle';Enable load balancing among tenants and for each tenant from the sys tenant
ALTER SYSTEM SET enable_rebalance = true TENANT = ALL;This statement sets the value of the
enable_rebalanceparameter totruefor the sys tenant and all user tenants.Enable load balancing for a user tenant from the current tenant
ALTER SYSTEM SET enable_rebalance = true;
For more information about the enable_rebalance parameter, see enable_rebalance.
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.
Perform a round of minor compaction to release the occupied memory resources.
For more information about how to manually initiate a minor compaction, see Manually initiate a minor compaction.
Increase the number of resource units
The following example describes how to increase the number of resource units for the mq_t1 tenant.
Log on to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys -pxxxx -AAccess the database named
oceanbase.use oceanbase;View the information about the
mq_t1tenant to obtain itsTENANT_ID.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-01 19:17:35.326317 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688363370009667411 | 1688363370009667411 | 1688363370009667411 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 1 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setIn the query result, the value of the
UNIT_NUMparameter is1, indicating that the tenant has one resource unit in each zone.View the resource units of the
mq_t1tenant.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in setThe query result shows that the
mq_t1tenant has one resource unit in each zone, and the three resource units belong to the same unit group.Change the value of
UNIT_NUMto 2 for themq_t1tenant.ALTER RESOURCE TENANT mq_t1 UNIT_NUM = 2;View the resource units of the
mq_t1tenant after modification.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1016 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.298237 | 2023-07-03 14:23:00.298237 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1017 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.300350 | 2023-07-03 14:23:00.300350 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1018 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.302460 | 2023-07-03 14:23:00.302460 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in set
The query result shows that the number of resource units in each zone is changed from 1 to 2 for the mq_t1 tenant. The tenant has one resource unit in each zone before the change, and two resource units in each zone after the change.
Decrease the number of resource units
The following example describes how to decrease the number of resource units of the mq_t1 tenant.
Log on to the
systenant of the cluster as therootuser.obclient -h172.xxx.xxx.xxx -P2883 -uroot@sys -pxxxx -AAccess the database named
oceanbase.use oceanbase;View the information about the
mq_t1tenant to obtain itsTENANT_ID.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-01 19:17:35.326317 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688364899374900659 | 1688364899374900659 | 1688364899148955397 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 2 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setIn the query result, the value of the
UNIT_NUMparameter is2, indicating that the tenant has two resource units in each zone.View the resource units of the
mq_t1tenant.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1007 | 1004 | ACTIVE | 1002 | 1001 | 2023-07-01 19:15:09.721728 | 2023-07-01 19:16:39.743467 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1009 | 1004 | ACTIVE | 1002 | 1001 | 2023-07-01 19:15:09.725952 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1011 | 1004 | ACTIVE | 1002 | 1001 | 2023-07-01 19:15:09.729124 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setThe query result shows that the
mq_t1tenant has two resource units in each zone. The resource units with the IDs 1007, 1009, and 1011 belong to the unit group with the ID 1001. The resource units with the IDs 1008, 1010, and 1012 belong to the unit group with the ID 1002.Change the value of
UNIT_NUMto 1 for themq_t1tenant.Randomly delete a unit group to decrease the number of resource units
ALTER RESOURCE TENANT mq_t1 UNIT_NUM = 1;For a scenario where each zone has two resource units, the system randomly deletes a unit group.
Delete a specified unit group to decrease the number of resource units
ALTER RESOURCE TENANT mq_t1 UNIT_NUM = 1 DELETE UNIT_GROUP =(1001);For a scenario where each zone has two resource units, the system deletes the specified unit group.
View the resource units of the
mq_t1tenant after modification.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in set
The query result shows that the number of resource units in each zone is changed from 2 to 1 for the mq_t1 tenant. The tenant has two resource units in each zone before the change, and one resource unit in each zone after the change.