Drop a resource unit

2023-07-28 02:55:42  Updated

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.

  1. Log on to the sys tenant of the cluster as the root user.

  2. 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 unit1 is to be dropped and unit1 has been allocated to pool1. If you want to remove unit1, you must create unit2 and allocate it to pool1 before you drop unit1.

    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;
    

Contact Us