You can also increase the UNIT_NUM value of the resource pool to scale out a tenant. At present, you cannot decrease the UNIT_NUM value for the resource pool to scale in a tenant.
Prerequisites
Before you perform a scale-out operation on a tenant, you must perform the following steps:
If the tenant is deleted, delete 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 delete a resource pool, see Delete a resource pool.
View the allocation of resources in the cluster to understand resource usage.
For more information about how to view the total amount of resources and the resource allocation on OBServer nodes, see View the resource information about a cluster.
Notice
When you increase the
UNIT_NUMvalue for a resource pool, ensure that the newUNIT_NUMvalue is smaller than or equal to the number of available OBServer nodes in each zone.
Modify the UNIT_NUM parameter of a tenant by using SQL statements
You can increase the value of the UNIT_NUM parameter to scale out a tenant.
Background
Assume that you have a cluster that has three zones, which are z1, z2, and z3, and each zone has three OBServer nodes. Create a user tenant named MySQL in the cluster. The following code shows the resource distribution of the tenant:
obclient> CREATE RESOURCE UNIT unit1 MAX_CPU 6, MIN_CPU 6, MEMORY_SIZE '36G', MAX_IOPS 1024, MIN_IOPS 1024, IOPS_WEIGHT=0, LOG_DISK_SIZE '2G';
obclient> CREATE RESOURCE POOL pool1 UNIT 'unit1', UNIT_NUM 1, ZONE_LIST ('z1','z2','z3');
obclient> CREATE TENANT MySQL resource_pool_list=('pool1');
Increase the value of the UNIT_NUM parameter
When the business volume increases, one resource unit in each zone is insufficient. In this case, you must increase the value of UNIT_NUM to improve the service capabilities of the tenant to meet increasing business needs.
Log on to the
systenant of the cluster as therootuser.Execute the following statement to go to the database named
oceanbase:obclient>USE oceanbase;Execute the following statement to query the resource configurations of the current tenant.
obclient> SELECT a.TENANT_NAME, b.RESOURCE_POOL_ID,b.NAME resource_pool_name,b.UNIT_CONFIG_ID,b. UNIT_COUNT FROM oceanbase.DBA_OB_TENANTS a,oceanbase.DBA_OB_RESOURCE_POOLS b WHERE b.TENANT_ID=a.TENANT_ID; +-------------+------------------+--------------------+----------------+------------+ | TENANT_NAME | RESOURCE_POOL_ID | resource_pool_name | UNIT_CONFIG_ID | UNIT_COUNT | +-------------+------------------+--------------------+----------------+------------+ | sys | 1 | sys_pool | 1 | 1 | | tenant1 | 1001 | pool1 | 1001 | 2 | | Oracle | 1002 | pool002 | 1002 | 1 | +-------------+------------------+--------------------+----------------+------------+ 3 rows in set obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE UNIT_CONFIG_ID='1001'; +----------------+-------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_CONFIG_ID | NAME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +----------------+-------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1001 | unit1 | 6 | 6 | 38654705664 | 2147483648 | 1024 | 1024 | 0 | +----------------+-------+---------+---------+-------------+---------------+----------+----------+-------------+ 1 row in setUNIT_COUNTindicates the number of resource units (UNIT_NUM) allocated to the current tenant.Execute the following statement to increase the value of
UNIT_NUM.
Note
You cannot increase the value of UNIT_NUM by specifying the unit_id.
obclient>ALTER RESOURCE TENANT MySQL UNIT_NUM = 2;
After the statement is executed, the system adds a resource unit to each zone.
More information
When you scale out a tenant, you can query the following internal tables or views for resource information about the tenant:
oceanbase.DBA_OB_UNIT_CONFIGS
The
DBA_OB_UNIT_CONFIGSview displays the unit_config information of all tenants in the current cluster.Example:
obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS; +----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_CONFIG_ID | NAME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1 | sys_unit_config | 2.5 | 2.5 | 17179869184 | 17179869184 | 25000 | 25000 | 2 | | 1001 | unit001 | 1 | 1 | 6442450944 | 19327352832 | 10000 | 10000 | 1 | | 1002 | unit002 | 1 | 1 | 6442450944 | 19327352832 | 10000 | 10000 | 1 | | 1003 | unit003 | 1 | 1 | 6442450944 | 19327352832 | 10000 | 10000 | 1 | | 1004 | unit004 | 1 | 1 | 6442450944 | 19327352832 | 10000 | 10000 | 1 | | 1005 | unit1 | 6 | 6 | 38654705664 | 2147483648 | 1024 | 1024 | 0 | +----------------+-----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setoceanbase.GV$OB_UNITS
The
GV$OB_UNITSview displays the resource allocation information of all tenants in the cluster.Sample statement:
obclient> SELECT * FROM oceanbase.GV$OB_UNITS\G *************************** 1. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 UNIT_ID: 1 TENANT_ID: 1 ZONE: zone1 MAX_CPU: 2.5 MIN_CPU: 2.5 MEMORY_SIZE: 17179869184 MAX_IOPS: 25000 MIN_IOPS: 25000 IOPS_WEIGHT: 2 LOG_DISK_SIZE: 17179869184 LOG_DISK_IN_USE: 191441460 DATA_DISK_IN_USE: 406847488 STATUS: NORMAL CREATE_TIME: 2022-07-19 11:04:39.226231 *************************** 2. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 UNIT_ID: 1001 TENANT_ID: 1001 ZONE: zone1 MAX_CPU: NULL MIN_CPU: NULL MEMORY_SIZE: 644245094 MAX_IOPS: NULL MIN_IOPS: NULL IOPS_WEIGHT: NULL LOG_DISK_SIZE: 1932735283 LOG_DISK_IN_USE: 155042605 DATA_DISK_IN_USE: 211812352 STATUS: NORMAL CREATE_TIME: 2022-07-19 13:48:36.308843 *************************** 3. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 UNIT_ID: 1001 TENANT_ID: 1002 ZONE: zone1 MAX_CPU: 1 MIN_CPU: 1 MEMORY_SIZE: 5798205850 MAX_IOPS: 10000 MIN_IOPS: 10000 IOPS_WEIGHT: 1 LOG_DISK_SIZE: 17394617549 LOG_DISK_IN_USE: 154632504 DATA_DISK_IN_USE: 121634816 STATUS: NORMAL CREATE_TIME: 2022-07-19 13:48:36.308843 *************************** 4. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 UNIT_ID: 1002 TENANT_ID: 1005 ZONE: zone1 MAX_CPU: NULL MIN_CPU: NULL MEMORY_SIZE: 644245094 MAX_IOPS: NULL MIN_IOPS: NULL IOPS_WEIGHT: NULL LOG_DISK_SIZE: 1932735283 LOG_DISK_IN_USE: 152132563 DATA_DISK_IN_USE: 211812352 STATUS: NORMAL CREATE_TIME: 2022-07-19 13:51:56.627867 *************************** 5. row *************************** SVR_IP: xx.xx.xx.xx SVR_PORT: 2882 UNIT_ID: 1002 TENANT_ID: 1006 ZONE: zone1 MAX_CPU: 1 MIN_CPU: 1 MEMORY_SIZE: 5798205850 MAX_IOPS: 10000 MIN_IOPS: 10000 IOPS_WEIGHT: 1 LOG_DISK_SIZE: 17394617549 LOG_DISK_IN_USE: 158023991 DATA_DISK_IN_USE: 134217728 STATUS: NORMAL CREATE_TIME: 2022-07-19 13:51:56.627867 5 rows in setoceanbase.DBA_OB_RESOURCE_POOLS
The
DBA_OB_RESOURCE_POOLSview displays the resource configurations of all resource pools in the current cluster.unit_countindicates the number of resource units in the resource pool.Sample statement:
obclient> SELECT * FROM oceanbase.DBA_OB_RESOURCE_POOLS; +------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | RESOURCE_POOL_ID | NAME | TENANT_ID | CREATE_TIME | MODIFY_TIME | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST | REPLICA_TYPE | +------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | 1 | sys_pool | 1 | 2022-07-19 11:05:18.168896 | 2022-07-19 11:05:18.175708 | 1 | 1 | zone1 | FULL | | 1001 | pool001 | 1002 | 2022-07-19 13:47:55.854548 | 2022-07-19 13:48:36.307978 | 1 | 1001 | zone1 | FULL | | 1002 | pool002 | 1006 | 2022-07-19 13:49:53.869792 | 2022-07-19 13:51:56.626742 | 1 | 1001 | zone1 | FULL | +------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ 3 rows in set