Purpose
This statement is used to drop a resource unit.
Notice
Before dropping a resource unit, make sure that the resource unit is not in use. If the resource unit is in use, you must first remove it from the resource pool before dropping it.
Syntax
DROP RESOURCE UNIT unit_name;
Parameters
| Parameter | Description |
|---|---|
| unit_name | The name of the resource unit to be dropped. |
Examples
If a resource unit is not assigned to a resource pool, you can directly drop it.
obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affectedIf a resource unit is assigned to a resource pool, you cannot directly drop it. You must first remove it from the resource pool before dropping it.
For example, in the following example, the resource unit
unit1is assigned to the resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');When you attempt to directly drop the resource unit
unit1, an error is returned.obclient> DROP RESOURCE UNIT unit1; ERROR 4634 (HY000): resource unit 'UNIT1' is referenced by some resource poolIf you still need to remove
unit1from the resource poolpool1, you can create a new resource unitunit2, assignunit2topool1, and then dropunit1. Here is an example:Create a new resource unit
unit2.obclient> CREATE RESOURCE UNIT unit2 MAX_CPU 4, MEMORY_SIZE '5G', MAX_IOPS 1280,LOG_DISK_SIZE '10G', MIN_CPU=4, MIN_IOPS=1024;Remove
unit1from the resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='';Notice
Each execution of the
ALTER RESOURCE POOLcommand can only add or remove one resource unit from the resource pool. Therefore, you need to first removeunit1and then addunit2.Assign
unit2to the resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='unit2';Drop the resource unit
unit1. The drop operation is successful.obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected
If you want to drop a resource unit that is assigned to a resource pool and also clean up the resource pool, you must first drop the resource pool and then drop the resource unit.
For example, in the following example, the resource unit
unit1is assigned to the resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');When you attempt to directly drop the resource unit
unit1, an error is returned.obclient> DROP RESOURCE UNIT unit1; ERROR 4634 (HY000): resource unit 'UNIT1' is referenced by some resource poolFirst, drop the resource pool
pool1, and then drop the resource unitunit1. The drop operation is successful.obclient> DROP RESOURCE POOL pool1; Query OK, 0 rows affectedobclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected