Purpose
You can use this statement to drop a resource unit.
Notice
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.
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 allocated to a resource pool, you can directly drop it.
obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affectedIf a resource unit is allocated to a resource pool, you cannot directly drop it. You must first remove the resource unit from the resource pool.
For example, in the following example, resource unit
unit1is allocated to resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');If you directly drop 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
unit1frompool1, you can first create a new resource unit namedunit2and allocateunit2topool1, and then dropunit1. Here is an example.Create a new resource unit named
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
unit1frompool1.obclient> ALTER RESOURCE POOL pool1 UNIT='';Notice
The
ALTER RESOURCE POOLstatement can add or remove only one resource unit to or from a resource pool at a time. Therefore, you must removeunit1from the resource pool and then addunit2to it.Allocate
unit2topool1.obclient> ALTER RESOURCE POOL pool1 UNIT='unit2';Drop
unit1. The drop operation is successful.obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected
If a resource unit is allocated to a resource pool, you must drop the resource pool and the resource unit.
For example, in the following example, resource unit
unit1is allocated to resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');If you directly drop resource unit
unit1, an error is returned.obclient> DROP RESOURCE UNIT unit1; ERROR 4634 (HY000): resource unit 'UNIT1' is referenced by some resource poolDrop resource pool
pool1and then drop resource unitunit1. The drop operations are successful.obclient> DROP RESOURCE POOL pool1; Query OK, 0 rows affectedobclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected