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 need to 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 has not been assigned to a resource pool, you can directly drop it.
obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affectedIf a resource unit has been assigned to a resource pool, you cannot directly drop it. You need to remove it from the resource pool before dropping it.
For example, in the following example, the resource unit
unit1has been assigned to the resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');If you 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 want to remove the resource unit
unit1from the resource poolpool1, you can create a new resource unitunit2and assign it to the resource poolpool1before dropping the resource unitunit1. 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 the resource unit
unit1from the resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='';Notice
Each time you execute the
ALTER RESOURCE POOLcommand, you can only add or remove one resource unit from the resource pool. Therefore, you need to removeunit1first and then addunit2.Assign the resource unit
unit2to the resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='unit2';Drop the resource unit
unit1. The operation is successful.obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected
If you want to drop a resource unit that has been assigned to a resource pool, you need to drop the resource pool first and then drop the resource unit.
For example, in the following example, the resource unit
unit1has been assigned to the resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');If you 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 poolDrop the resource pool
pool1first and then drop the resource unitunit1. The operation is successful.obclient> DROP RESOURCE POOL pool1; Query OK, 0 rows affectedobclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected