You can drop a resource unit that is no longer in use.
Prerequisites
Before you drop a resource unit, make sure that the resource unit is not in use. To drop a resource unit that is in use, remove it from the resource pool first.
Before you drop a resource unit, you must check whether the resource unit is in use.
Log on to the
systenant of the cluster as therootuser.Execute the following statement to check whether the resource unit is allocated to a resource pool:
Sample code:
obclient> SELECT a.UNIT_CONFIG_ID, a.NAME FROM oceanbase.DBA_OB_UNIT_CONFIGS a,oceanbase.DBA_OB_RESOURCE_POOLS b WHERE b.UNIT_CONFIG_ID=a.UNIT_CONFIG_ID; +----------------+-----------------+ | UNIT_CONFIG_ID | NAME | +----------------+-----------------+ | 1 | sys_unit_config | | 1001 | unit001 | | 1001 | unit001 | +----------------+-----------------+ 3 rows in set
If the resource unit name is not in the name column in the query result, the resource unit is not allocated to the resource pool. If the resource unit name is in the name column of the query result, the resource unit is allocated to the resource pool.
Procedure
Resource unit not in use
If the resource unit is not allocated to a resource pool, you can directly drop the resource unit. Syntax:
obclient> DROP RESOURCE UNIT unit1;Notice
This statement
drops only a single resource unit at a time.Resource unit in use
If the resource unit has been allocated to a resource pool, you must specify a new resource unit for the resource pool before you drop the resource unit.
Sample code:
Assume that
unit1is to be dropped andunit1has been allocated topool1. If you want to removeunit1, you must createunit2and allocate it topool1before you dropunit1.obclient> CREATE RESOURCE UNIT unit2 MAX_CPU=4, MIN_CPU=4, MEMORY_SIZE='5G', MAX_IOPS=1024, MIN_IOPS=1024, IOPS_WEIGHT=0, LOG_DISK_SIZE='2G'; obclient> ALTER RESOURCE POOL pool1 UNIT='unit2'; obclient> DROP RESOURCE UNIT unit1;