Modify the unit configs for a tenant

2024-03-05 01:54:26  Updated

Tenant scaling aims to improve or reduce the service capabilities of the tenant, including the computing and storage capacities. To meet this purpose, you can improve the service capabilities of a single node or add service nodes. This topic describes how to upgrade or downgrade the unit configs of a tenant to improve or reduce the service capabilities of a single node, thereby implementing the scaling of the tenant.

Prerequisites

Before you perform a scale-in or scale-out operation on a tenant, you must perform the following steps:

  • If the tenant is deleted, drop the resource pool of the tenant to release resources. Resources in an idle resource pool are also considered occupied resources.

    For more information about how to drop a resource pool, see Drop a resource pool.

  • Perform a round of minor compaction to release the occupied memory resources.

    For more information about how to manually initiate a minor compaction, see Manually initiate a minor compaction.

Considerations

If you want to upgrade the unit configs, the total amount of resources after adjustment must meet the following requirements:

Sum(min_cpu) <= CPU_CAPACITY;
Sum(max_cpu) <= CPU_CAPACITY * resource_hard_limit;
Sum(memory_size) <= MEM_CAPACITY;
Sum(log_disk_size) <= LOG_DISK_CAPACITY;

Take note of the following parameter description:

  • CPU_CAPACITY: the total CPU capacity.

  • MEM_CAPACITY: the total memory capacity.

  • LOG_DISK_CAPACITY: the total capacity of the log disk.

    The total capacity of the log disk is jointly controlled by the log_disk_size and log_disk_percentage parameters. log_disk_size specifies the size of the disk where REDO logs are stored, and the default value is 0. log_disk_percentage specifies the percentage of the disk space occupied by REDO logs, and the default value is 0. Rules for using the two parameters are as follows:

    • If the value of log_disk_size is 0 but the value of log_disk_percentage is not 0, the system allocates log disk space based on the value of log_disk_percentage.

    • If the value of log_disk_size is not 0, the system allocates log disk space based on the value of log_disk_size, regardless of whether the value of log_disk_percentage is 0.

    • If the values of both log_disk_size and log_disk_percentage are 0, the system automatically calculates the percentage of the disk space occupied by REDO logs. The percentage depends on whether the disk is shared by REDO logs and data.

      • If the disk is shared, the percentage of the disk space occupied by REDO logs is 30%.

      • If the disk is exclusive for REDO logs, the percentage of the disk space occupied by REDO logs is 90%.

    For more information about the log_disk_size parameter, see log_disk_size.

    For more information about the log_disk_percentage parameter, see log_disk_percentage.

  • resource_hard_limit: a specific system parameter.

    The system allocates CPU resources based on the value of the resource_hard_limit parameter. The value range is [0, 10000]. The default value is 100, indicating that over-allocation is not allowed.

    For more information about the resource_hard_limit parameter, see resource_hard_limit.

Modify the unit config

When you upgrade or downgrade the unit configs of a tenant for scaling, two cases exist.

  • If the tenant uses an independent unit config, you can directly modify its unit config.

  • If multiple tenants use the same unit config, you must replace the original unit config of the target tenant with a new one.

Obtain the ID of the unit config

Verify that the tenant uses an independent unit config. Run the following command to obtain the ID of the unit config used by the current tenant.

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

    obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -A
    
  2. Query the ID of the unit config used by the current tenant.

    obclient> SELECT a.TENANT_NAME, b.UNIT_CONFIG_ID  FROM oceanbase.DBA_OB_TENANTS a,oceanbase.DBA_OB_RESOURCE_POOLS b WHERE b.TENANT_ID=a.TENANT_ID;
    +----------------+----------------+
    | TENANT_NAME    | UNIT_CONFIG_ID |
    +----------------+----------------+
    | sys            |              1 |
    | midas0_3790    |           1008 |
    | midas0_3790    |           1008 |
    | midas0_3790    |           1007 |
    | mq_t1          |           1006 |
    | oracle_tenant1 |           1003 |
    +----------------+----------------+
    6 rows in set
    

In the query result, if the UNIT_CONFIG_ID value of the current tenant is the same as other tenants, multiple tenants use the same unit config.

If the UNIT_CONFIG_ID value of the current tenant is different from those of other tenants, the current tenant uses an independent unit config. For example, the UNIT_CONFIG_ID value of the mq_t1 tenant is different from those of other tenants. This indicates that the mq_t1 tenant uses an independent unit config.

Target tenant uses an independent unit config

If the target tenant uses an independent unit config, you can directly modify its unit_config parameter for scaling.

Here is an example:

To scale out the CPU resources of the mq_t1 tenant, perform the following steps:

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

    obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -A
    
  2. Access the database named oceanbase.

    obclient>USE oceanbase;
    
  3. Query the UNIT_CONFIG_ID value of the target tenant.

    obclient> SELECT a.TENANT_NAME, b.UNIT_CONFIG_ID  FROM oceanbase.DBA_OB_TENANTS a,oceanbase.DBA_OB_RESOURCE_POOLS b WHERE b.TENANT_ID=a.TENANT_ID;
    +----------------+----------------+
    | TENANT_NAME    | UNIT_CONFIG_ID |
    +----------------+----------------+
    | sys            |              1 |
    | midas0_3790    |           1008 |
    | midas0_3790    |           1008 |
    | midas0_3790    |           1007 |
    | mq_t1          |           1006 |
    | oracle_tenant1 |           1003 |
    +----------------+----------------+
    6 rows in set
    
  4. Query the details about the unit config used by the tenant.

    obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE UNIT_CONFIG_ID='1006';
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    | UNIT_CONFIG_ID | NAME           | CREATE_TIME                | MODIFY_TIME                | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    |           1006 | S2_unit_config | 2022-11-03 17:13:29.021410 | 2022-11-03 17:13:29.021410 |       3 |       3 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    1 row in set
    
  5. Modify the unit config.

    Upgrade the configurations of the unit config named S2_unit_config.

    obclient> ALTER RESOURCE UNIT S2_unit_config MAX_CPU 5, MIN_CPU 5;
    
  6. Query the current unit config of the tenant to verify whether the unit config is successfully modified.

    obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE UNIT_CONFIG_ID='1006';
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    | UNIT_CONFIG_ID | NAME           | CREATE_TIME                | MODIFY_TIME                | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    |           1006 | S2_unit_config | 2022-11-03 17:13:29.021410 | 2023-01-12 10:28:57.606507 |       5 |       5 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    1 row in set
    

In the query result, if the MAX_CPU and MIN_CPU fields are modified to new values, the unit config is modified.

Multiple tenants use the same unit config

If multiple tenants use the same unit config, you cannot simply upgrade or downgrade the unit config for scaling. This is because the modification will apply to all tenants that use this unit config.

In this case, you must create an independent unit config and then replace the original unit config of the target tenant with the new one.

To adjust the CPU resources for the mq_t1 tenant, perform the following steps:

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

    obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -A
    
  2. Execute the following statement to go to the database named oceanbase:

    obclient>use oceanbase;
    
  3. Query the UNIT_CONFIG_ID and RESOURCE_POOL_NAME values of the target tenant.

    obclient> SELECT a.TENANT_NAME, b.NAME RESOURCE_POOL_NAME, b.UNIT_CONFIG_ID  FROM oceanbase.DBA_OB_TENANTS a,oceanbase.DBA_OB_RESOURCE_POOLS b WHERE b.TENANT_ID=a.TENANT_ID;
    +----------------+---------------------+----------------+
    | TENANT_NAME    | RESOURCE_POOL_NAME  | UNIT_CONFIG_ID |
    +----------------+---------------------+----------------+
    | sys            | sys_pool            |              1 |
    | midas0_3790    | midas0_3790_pool_z3 |           1008 |
    | midas0_3790    | midas0_3790_pool_z2 |           1008 |
    | midas0_3790    | midas0_3790_pool_z1 |           1007 |
    | mq_t1          | mq_pool_01          |           1006 |
    | oracle_tenant1 | oracle_pool_01      |           1003 |
    +----------------+---------------------+----------------+
    6 rows in set
    
  4. Query the details about the unit config used by the tenant.

    obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE UNIT_CONFIG_ID='1006';
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    | UNIT_CONFIG_ID | NAME           | CREATE_TIME                | MODIFY_TIME                | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    |           1006 | S2_unit_config | 2022-11-03 17:13:29.021410 | 2023-01-12 10:28:57.606507 |       5 |       5 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
    +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    1 row in set
    
  5. Create an independent unit config and set the sizes of the resource items to desired values.

    Create a unit config named new_S2_unit_config which has higher configurations than the current unit config.

    obclient> CREATE RESOURCE UNIT new_S2_unit_config MAX_CPU = 5, MIN_CPU = 5, MEMORY_SIZE = '12884901888',LOG_DISK_SIZE = '38654705664',MAX_IOPS = 30000, MIN_IOPS  = 30000, IOPS_WEIGHT=3;
    
  6. Replace the original unit config of the target tenant with the new one.

    obclient> ALTER RESOURCE POOL mq_pool_01 unit='new_S2_unit_config';
    
  7. Query the current unit config of the tenant to verify whether the unit config is successfully modified.

    obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE UNIT_CONFIG_ID='1006';
    +----------------+--------------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    | UNIT_CONFIG_ID | NAME               | CREATE_TIME                | MODIFY_TIME                | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT |
    +----------------+--------------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    |           1006 | new_S2_unit_config | 2022-12-03 17:13:29.021410 | 2022-12-03 17:13:29.021410 |       5 |       5 | 12884901888 |   38654705664 |    30000 |    30000 |           3 |
    +----------------+--------------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------+----------+-------------+
    1 row in set
    

More information

  • Query the GV$OB_SERVERS view for the upper limit of each resource item.

    For more information about the GV$OB_SERVERS view, see GV$OB_SERVERS.

    Here is an example:

    obclient> SELECT * FROM oceanbase.GV$OB_SERVERS;
    +-------------+----------+--------------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
    | SVR_IP      | SVR_PORT | ZONE         | SQL_PORT | CPU_CAPACITY | CPU_CAPACITY_MAX | CPU_ASSIGNED | CPU_ASSIGNED_MAX | MEM_CAPACITY | MEM_ASSIGNED | LOG_DISK_CAPACITY | LOG_DISK_ASSIGNED | LOG_DISK_IN_USE | DATA_DISK_CAPACITY | DATA_DISK_IN_USE | DATA_DISK_HEALTH_STATUS | MEMORY_LIMIT | DATA_DISK_ABNORMAL_TIME | SSL_CERT_EXPIRED_TIME |
    +-------------+----------+--------------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
    | xx.xx.xx.47  |     2882 | sa128_obv4_1 |     2881 |           51 |               51 |          6.5 |              6.5 | 161061273600 |  19327352832 |       96569655296 |       57982058496 |      8858370048 |      1030284640256 |       8258584576 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    | xx.xx.xx.158 |     2882 | sa128_obv4_3 |     2881 |           51 |               51 |           19 |               22 | 182536110080 |  81604378624 |      386345730048 |      176093659136 |     65431142400 |      4249937248256 |      49568284672 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    | xx.xx.xx.43  |     2882 | sa128_obv4_1 |     2881 |           51 |               51 |           19 |               22 | 161061273600 |  81604378624 |      386345730048 |      176093659136 |     76705431552 |      4249937248256 |      49572478976 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    | xx.xx.xx.106 |     2882 | sa128_obv4_2 |     2881 |           51 |               51 |           19 |               22 | 161061273600 |  81604378624 |      386345730048 |      176093659136 |     65431142400 |      4249937248256 |      49729765376 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    | xx.xx.xx.81  |     2882 | sa128_obv4_2 |     2881 |           51 |               51 |          6.5 |              6.5 | 161061273600 |  19327352832 |       96569655296 |       57982058496 |      8858370048 |      1030284640256 |       8269070336 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    | xx.xx.xx.19  |     2882 | sa128_obv4_3 |     2881 |           51 |               51 |            5 |                5 | 182536110080 |  12884901888 |       96569655296 |       38654705664 |      5838471168 |      1030284640256 |       5649727488 | NORMAL                  | 214748364800 | NULL                    | NULL                  |
    +-------------+----------+--------------+----------+--------------+------------------+--------------+------------------+--------------+--------------+-------------------+-------------------+-----------------+--------------------+------------------+-------------------------+--------------+-------------------------+-----------------------+
    6 rows in set
    
  • Query the GV$OB_UNITS view for the resource allocation of all tenants in the cluster.

    For more information about the GV$OB_UNITS view, see GV$OB_UNITS.

    Here is an example:

    obclient> select SVR_IP,SVR_PORT,UNIT_ID,TENANT_ID,MAX_CPU,MIN_CPU,ceil(MEMORY_SIZE/1024/1024/1024) MEMORY_SIZE_G,MAX_IOPS,MIN_IOPS,IOPS_WEIGHT,ceil(LOG_DISK_SIZE/1024/1024/1024) LOG_DISK_SIZE_G,ceil(LOG_DISK_IN_USE/1024/1024/1024) LOG_DISK_IN_USE_G,ceil(DATA_DISK_IN_USE/1024/1024/1024) DATA_DISK_IN_USE_G,STATUS,CREATE_TIME  from oceanbase.GV$OB_UNITS;
    +--------------+----------+---------+-----------+---------+---------+---------------+----------+----------+-------------+-----------------+-------------------+--------------------+--------+----------------------------+
    | SVR_IP       | SVR_PORT | UNIT_ID | TENANT_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE_G | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | LOG_DISK_SIZE_G | LOG_DISK_IN_USE_G | DATA_DISK_IN_USE_G | STATUS | CREATE_TIME                |
    +--------------+----------+---------+-----------+---------+---------+---------------+----------+----------+-------------+-----------------+-------------------+--------------------+--------+----------------------------+
    | xx.xx.xx.43  |     2882 |       1 |         1 |       5 |       2 |            32 |    10000 |    10000 |           1 |              32 |                26 |                 11 | NORMAL | 2022-11-03 15:36:31.693272 |
    | xx.xx.xx.43  |     2882 |    1001 |      1001 |    NULL |    NULL |             4 |     NULL |     NULL |        NULL |              10 |                 8 |                 16 | NORMAL | 2022-11-03 17:33:15.340453 |
    | xx.xx.xx.43  |     2882 |    1001 |      1002 |      12 |      12 |            29 |    60000 |    60000 |           6 |              87 |                37 |                 21 | NORMAL | 2022-11-03 17:33:15.340453 |
    | xx.xx.xx.43  |     2882 |    1007 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 0 |                  0 | NORMAL | 2023-01-04 23:50:57.990761 |
    | xx.xx.xx.43  |     2882 |    1007 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 2 |                  1 | NORMAL | 2023-01-04 23:50:57.990761 |
    | xx.xx.xx.158 |     2882 |       3 |         1 |       5 |       2 |            32 |    10000 |    10000 |           1 |              32 |                26 |                 11 | NORMAL | 2022-11-03 15:36:31.690365 |
    | xx.xx.xx.158 |     2882 |    1003 |      1001 |    NULL |    NULL |             4 |     NULL |     NULL |        NULL |              10 |                 8 |                 16 | NORMAL | 2022-11-03 17:33:15.344035 |
    | xx.xx.xx.158 |     2882 |    1003 |      1002 |      12 |      12 |            29 |    15000 |    15000 |           1 |              87 |                26 |                 21 | NORMAL | 2022-11-03 17:33:15.344035 |
    | xx.xx.xx.158 |     2882 |    1009 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 0 |                  0 | NORMAL | 2023-01-04 23:50:57.998665 |
    | xx.xx.xx.158 |     2882 |    1009 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 2 |                  1 | NORMAL | 2023-01-04 23:50:57.998665 |
    | xx.xx.xx.47  |     2882 |    1004 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 3 |                  6 | NORMAL | 2023-01-04 18:32:08.216823 |
    | xx.xx.xx.47  |     2882 |    1004 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 3 |                  1 | NORMAL | 2023-01-04 18:32:08.216823 |
    | xx.xx.xx.47  |     2882 |    1010 |      1009 |    NULL |    NULL |             1 |     NULL |     NULL |        NULL |               2 |                 2 |                  3 | NORMAL | 2023-01-06 16:52:53.867318 |
    | xx.xx.xx.47  |     2882 |    1010 |      1010 |     1.5 |     1.5 |             5 |    15000 |    15000 |           1 |              17 |                 2 |                  1 | NORMAL | 2023-01-06 16:52:53.867318 |
    | xx.xx.xx.19  |     2882 |    1006 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 3 |                  5 | NORMAL | 2023-01-04 18:32:08.217376 |
    | xx.xx.xx.19  |     2882 |    1006 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 3 |                  1 | NORMAL | 2023-01-04 18:32:08.217376 |
    | xx.xx.xx.81  |     2882 |    1005 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 3 |                  6 | NORMAL | 2023-01-04 18:32:08.217390 |
    | xx.xx.xx.81  |     2882 |    1005 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 3 |                  1 | NORMAL | 2023-01-04 18:32:08.217390 |
    | xx.xx.xx.81  |     2882 |    1011 |      1009 |    NULL |    NULL |             1 |     NULL |     NULL |        NULL |               2 |                 2 |                  3 | NORMAL | 2023-01-06 16:52:53.867944 |
    | xx.xx.xx.81  |     2882 |    1011 |      1010 |     1.5 |     1.5 |             5 |    15000 |    15000 |           1 |              17 |                 2 |                  1 | NORMAL | 2023-01-06 16:52:53.867944 |
    | xx.xx.xx.106 |     2882 |       2 |         1 |       5 |       2 |            32 |    10000 |    10000 |           1 |              32 |                26 |                 11 | NORMAL | 2022-11-03 15:36:31.689252 |
    | xx.xx.xx.106 |     2882 |    1002 |      1001 |    NULL |    NULL |             4 |     NULL |     NULL |        NULL |              10 |                 8 |                 16 | NORMAL | 2022-11-03 17:33:15.344232 |
    | xx.xx.xx.106 |     2882 |    1002 |      1002 |      12 |      12 |            29 |    15000 |    15000 |           1 |              87 |                26 |                 21 | NORMAL | 2022-11-03 17:33:15.344232 |
    | xx.xx.xx.106 |     2882 |    1008 |      1007 |    NULL |    NULL |             2 |     NULL |     NULL |        NULL |               4 |                 0 |                  0 | NORMAL | 2023-01-04 23:50:57.995715 |
    | xx.xx.xx.106 |     2882 |    1008 |      1008 |       5 |       5 |            11 |    30000 |    30000 |           3 |              33 |                 2 |                  1 | NORMAL | 2023-01-04 23:50:57.995715 |
    +--------------+----------+---------+-----------+---------+---------+---------------+----------+----------+-------------+-----------------+-------------------+--------------------+--------+----------------------------+
    25 rows in set
    

References

Contact Us