Description
This statement is used to drop a resource unit.
Notice
Before deleting a resource unit, ensure it is not currently in use. If the resource unit is being used, you must remove it from the resource pool before deleting it.
Syntax
DROP RESOURCE UNIT unit_name;
Parameters
Parameters |
Description |
|---|---|
| unit_name | The name of the resource unit to be deleted. |
Examples
When a resource unit is not assigned to a resource pool, you can directly delete the resource unit
unit1.obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affectedIf a resource unit has been assigned to a resource pool and you only want to delete the resource unit, you cannot delete it directly. You must first remove it from the resource pool before deleting it.
For example, in the following example, resource unit
unit1has been assigned to resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');An error is reported when directly deleting the resource unit
unit1.obclient> DROP RESOURCE UNIT unit1; ERROR 4634 (HY000): resource unit 'UNIT1' is referenced by some resource poolIn this case, if you still need to remove
unit1from resource poolpool1, you can first create a new resource unitunit2and assignunit2topool1, and then deleteunit1. 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
unit1from resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='';Notice
Because each execution of the
ALTER RESOURCE POOLstatement can only add or remove one resource unit to a resource pool, you must first removeunit1and then addunit2.Assign
unit2to the resource poolpool1.obclient> ALTER RESOURCE POOL pool1 UNIT='unit2';Delete the resource unit
unit1again. The deletion succeeds.obclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected
If a resource unit has already been assigned to a resource pool and you want to clean up both the resource pool and the resource unit, you must delete the resource pool first, and then delete the resource unit.
For example, in the following example, resource unit
unit1has been assigned to resource poolpool1.obclient> CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM=1, ZONE_LIST=('zone2');An error is reported when directly deleting the resource unit
unit1.obclient> DROP RESOURCE UNIT unit1; ERROR 4634 (HY000): resource unit 'UNIT1' is referenced by some resource poolFirst, delete the resource pool
pool1, then delete the resource unitunit1. The deletion is successful.obclient> DROP RESOURCE POOL pool1; Query OK, 0 rows affectedobclient> DROP RESOURCE UNIT unit1; Query OK, 0 rows affected