---
title: 容器化部署的 OceanBase 集群如何增加可使用资源-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于容器化部署的 OceanBase 集群如何增加可使用资源相关的常见问题和使用技巧，帮助您快速解决容器化部署的 OceanBase 集群如何增加可使用资源的难题。
---
切换语言

- 简体中文
- English

划线反馈

# 容器化部署的 OceanBase 集群如何增加可使用资源

更新时间：2026-06-10 01:56

适用版本： V1.4.x、V2.1.x、V2.2.x、V3.1.x、V3.2.x、V4.0.x、V4.1.x、V4.2.x 内容类型：How-to  

容器化部署的 OceanBase 集群在初始创建时配置的 CPU/Memory 资源较少，导致不能创建规格较大的租户。而容器所在的宿主机服务器可使用的资源还比较多，所以希望利用这些宿主机剩余的资源来为 OceanBase 集群扩容。

## 适用版本

OceanBase 数据库的各版本

## 操作步骤

1. 检查服务器可用的资源 CPU/Memory/Disk space。

   ```
   # lscpu
   # free -h
   # df -Th

   ```
 2. 修改 OBServer 容器可以使用的 CPU/Memory 资源限制。

   ```
   $ docker update --cpu-quota xxx --cpuset-cpus "0-xxx" --memory xxxG observer1

   ```
 3. 登录数据库，检查目前可用的资源 CPU/Memory/Disk space，综合实际情况调整 CPU/Memory/Data_size 参数。

   ```
   [root@localhost /root]# mysql -h127.0.0.1 -uroot@sys -P2881 -pxxx
   MySQL [(none)]>
   show parameters like 'cpu_count';
   show parameters like 'memory_limit';
   show parameters like 'datafile_dize';
   ALTER SYSTEM SET cpu_count = 'xx';
   ALTER SYSTEM SET memory_limit='xxG';
   ALTER SYSTEM SET datafile_size='xxG';

   ```
 4. 退出数据库，重启 OBServer 容器。

   ```
   # docker stop observer
   # docker start observer

   ```
 5. 等待 20 秒左右，重新登录数据库，检查目前可用的资源 CPU/Memory/Data_size。

   ```
   [root@localhost /root]# mysql -h127.0.0.1 -uroot@sys -P2881 -pxxx
   MySQL [(none)]>
   use oceanbase;
   SELECT
   svr_ip,
   svr_port,
   zone,
   cpu_total,
   cpu_assigned,
   cpu_max_assigned,
   cpu_total - cpu_max_assigned cpu_free,
   round(mem_total / 1024 / 1024 / 1024, 1) "mem_total(G)",
   round(mem_assigned / 1024 / 1024 / 1024, 1) "mem_assigned(G)",
   round(mem_max_assigned / 1024 / 1024 / 1024, 1) "mem_max_assigned(G)",
   round((mem_total - mem_max_assigned) / 1024 / 1024 / 1024, 1) "mem_free(G)",
   round(disk_total / 1024 / 1024 / 1024, 1) "disk_total(G)",
   round(disk_assigned / 1024 / 1024 / 1024, 1) "disk_assigned(G)",
   disk_assigned_percent,
   unit_num
   FROM
   __all_virtual_server_stat
   ORDER BY
   zone\G

   ```

## 更多信息

一个调整的范例如下。

```
[root@localhost /root]# mysql -h127.0.0.1 -uroot@sys -P2881 -pxxx
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221703047
Server version: 5.7.25 OceanBase 3.2.3.3 (r107010022023021010-264a76a4fa7b5ff429149d60ca051391dc4176e9) (Built Feb 10 2023 10:44:53)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> use oceanbase;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [oceanbase]> SELECT
    -> svr_ip,
    -> svr_port,
    -> zone,
    -> cpu_total,
    -> cpu_assigned,
    -> cpu_max_assigned,
    -> cpu_total - cpu_max_assigned cpu_free,
    -> round(mem_total / 1024 / 1024 / 1024, 1) "mem_total(G)",
    -> round(mem_assigned / 1024 / 1024 / 1024, 1) "mem_assigned(G)",
    -> round(mem_max_assigned / 1024 / 1024 / 1024, 1) "mem_max_assigned(G)",
    -> round((mem_total - mem_max_assigned) / 1024 / 1024 / 1024, 1) "mem_free(G)",
    -> round(disk_total / 1024 / 1024 / 1024, 1) "disk_total(G)",
    -> round(disk_assigned / 1024 / 1024 / 1024, 1) "disk_assigned(G)",
    -> disk_assigned_percent,
    -> unit_num
    -> FROM
    -> __all_virtual_server_stat
    -> ORDER BY
    -> zone\G
*************************** 1. row ***************************
               svr_ip: xx.xx.xx.xx
             svr_port: 2882
                 zone: zone_1
            cpu_total: 6
         cpu_assigned: 2
     cpu_max_assigned: 2
             cpu_free: 4
         mem_total(G): 7.0
      mem_assigned(G): 1.8
  mem_max_assigned(G): 2.1
          mem_free(G): 4.9
        disk_total(G): 100.0
     disk_assigned(G): 100.0
disk_assigned_percent: 100
             unit_num: 1
1 row in set (0.01 sec)

MySQL [oceanbase]> CREATE RESOURCE UNIT IF NOT EXISTS unit2
    -> max_cpu 5,
    -> min_cpu 5,
    -> max_memory '10G',
    -> min_memory '10G',
    -> max_session_num 65535,
    -> max_iops 1250,
    -> min_iops 1250,
    -> max_disk_size '120G';
Query OK, 0 rows affected (0.01 sec)

MySQL [oceanbase]> CREATE RESOURCE POOL IF NOT EXISTS pool2
    -> unit = 'unit2',
    -> unit_num = 1,
    -> zone_list =('zone_1');
ERROR 4624 (HY000):  machine resource 'zone_1' is not enough to hold a new unit

MySQL [oceanbase]> show parameters like 'cpu_count';
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name      | data_type | value | info                                                                                                                                                                             | section  | scope   | source  | edit_level        |
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | cpu_count | NULL      | 8     | the number of CPU\'s in the system. If this parameter is set to zero, the number will be set according to sysconf; otherwise, this parameter is used. Range: [0,+∞) in integer   | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
1 row in set (0.01 sec)

MySQL [oceanbase]> show parameters like 'memory_limit';
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name         | data_type | value | info                                                                                | section  | scope   | source  | edit_level        |
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | memory_limit | NULL      | 15G   | the size of the memory reserved for internal use(for testing purpose). Range: [0M,) | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
1 row in set (0.00 sec)

MySQL [oceanbase]> show parameters like 'datafile_size';
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name          | data_type | value | info                                    | section | scope   | source  | edit_level        |
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | datafile_size | NULL      | 100G  | size of the data file. Range: [0, +∞)   | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
1 row in set (0.00 sec)

$ docker update --cpu-quota 1500000 --cpuset-cpus "0-14" --memory 28G observer1

MySQL [oceanbase]> ALTER SYSTEM SET cpu_count = '15';
Query OK, 0 rows affected (0.06 sec)

MySQL [oceanbase]> ALTER SYSTEM SET memory_limit='25G';
Query OK, 0 rows affected (0.04 sec)

MySQL [oceanbase]> ALTER SYSTEM SET datafile_size='150G';
Query OK, 0 rows affected (0.05 sec)

MySQL [oceanbase]> show parameters like 'cpu_count';
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name      | data_type | value | info                                                                                                                                                                             | section  | scope   | source  | edit_level        |
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | cpu_count | NULL      | 15    | the number of CPU\'s in the system. If this parameter is set to zero, the number will be set according to sysconf; otherwise, this parameter is used. Range: [0,+∞) in integer   | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+-----------+-----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
1 row in set (0.00 sec)

MySQL [oceanbase]> show parameters like 'memory_limit';
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name         | data_type | value | info                                                                                | section  | scope   | source  | edit_level        |
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | memory_limit | NULL      | 25G   | the size of the memory reserved for internal use(for testing purpose). Range: [0M,) | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+--------------+-----------+-------+-------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
1 row in set (0.00 sec)

MySQL [oceanbase]> show parameters like 'datafile_size';
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
| zone   | svr_type | svr_ip        | svr_port | name          | data_type | value | info                                    | section | scope   | source  | edit_level        |
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
| zone_1 | observer | xx.xx.xx.xx |     2882 | datafile_size | NULL      | 150G  | size of the data file. Range: [0, +∞)   | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+--------+----------+---------------+----------+---------------+-----------+-------+-----------------------------------------+---------+---------+---------+-------------------+
1 row in set (0.00 sec)

Aborted

[root@localhost /root]# docker stop observer
observer

[root@localhost /root]# docker start observer
observer

[root@localhost /root]# mysql -h127.0.0.1 -uroot@sys -P2881 -pWElcome12#_
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221487684
Server version: 5.7.25 OceanBase 3.2.3.3 (r107010022023021010-264a76a4fa7b5ff429149d60ca051391dc4176e9) (Built Feb 10 2023 10:44:53)

Database changed
MySQL [oceanbase]> SELECT
    -> svr_ip,
    -> svr_port,
    -> zone,
    -> cpu_total,
    -> cpu_assigned,
    -> cpu_max_assigned,
    -> cpu_total - cpu_max_assigned cpu_free,
    -> round(mem_total / 1024 / 1024 / 1024, 1) "mem_total(G)",
    -> round(mem_assigned / 1024 / 1024 / 1024, 1) "mem_assigned(G)",
    -> round(mem_max_assigned / 1024 / 1024 / 1024, 1) "mem_max_assigned(G)",
    -> round((mem_total - mem_max_assigned) / 1024 / 1024 / 1024, 1) "mem_free(G)",
    -> round(disk_total / 1024 / 1024 / 1024, 1) "disk_total(G)",
    -> round(disk_assigned / 1024 / 1024 / 1024, 1) "disk_assigned(G)",
    -> disk_assigned_percent,
    -> unit_num
    -> FROM
    -> __all_virtual_server_stat
    -> ORDER BY
    -> zone\G
*************************** 1. row ***************************
               svr_ip: xx.xx.xx.xx
             svr_port: 2882
                 zone: zone_1
            cpu_total: 13
         cpu_assigned: 2
     cpu_max_assigned: 2
             cpu_free: 11
         mem_total(G): 17.0
      mem_assigned(G): 1.8
  mem_max_assigned(G): 2.1
          mem_free(G): 14.9
        disk_total(G): 150.0
     disk_assigned(G): 100.0
disk_assigned_percent: 66
             unit_num: 1
1 row in set (0.01 sec)

MySQL [oceanbase]> select * from __all_unit_config;
+----------------------------+----------------------------+----------------+---------------------------+---------+---------+-------------+-------------+----------+----------+---------------+---------------------+
| gmt_create                 | gmt_modified               | unit_config_id | name                      | max_cpu | min_cpu | max_memory  | min_memory  | max_iops | min_iops | max_disk_size | max_session_num     |
+----------------------------+----------------------------+----------------+---------------------------+---------+---------+-------------+-------------+----------+----------+---------------+---------------------+
| 2023-05-26 15:45:51.855135 | 2023-05-26 15:47:10.376729 |              1 | sys_unit_config           |       2 |       2 |  2254857830 |  1879048192 |    10000 |     5000 |  107374182400 | 9223372036854775807 |
| 2023-05-26 15:47:15.505955 | 2023-05-26 15:47:15.505955 |           1001 | B_unit_config             |       1 |       1 |  6442450944 |  6442450944 |     1250 |     1250 |  128849018880 |                 375 |
| 2023-05-26 15:47:15.508045 | 2023-05-26 15:47:15.508045 |           1002 | LogOnlyNormal_unit_config |       1 |       1 |  2147483648 |  2147483648 |     1000 |     1000 |  536870912000 |                 300 |
| 2023-05-26 15:47:15.511211 | 2023-05-26 15:47:15.511211 |           1003 | LogOnlySystem_unit_config |       5 |       5 | 37580963840 | 37580963840 |     5000 |     5000 |  536870912000 |                1500 |
| 2023-05-26 15:47:15.513326 | 2023-05-26 15:47:15.513326 |           1004 | S0_unit_config            |       2 |       2 | 12884901888 | 12884901888 |     2500 |     2500 |  536870912000 |                 750 |
| 2023-05-26 15:47:15.516455 | 2023-05-26 15:47:15.516455 |           1005 | S1_unit_config            |       4 |       4 | 25769803776 | 25769803776 |     3000 |     3000 |  536870912000 |                1000 |
| 2023-05-26 15:47:15.518569 | 2023-05-26 15:47:15.518569 |           1006 | S2_unit_config            |       6 |       6 | 34359738368 | 34359738368 |     4000 |     4000 |  536870912000 |                1500 |
| 2023-05-26 15:47:15.521700 | 2023-05-26 15:47:15.521700 |           1007 | S3_unit_config            |       8 |       8 | 42949672960 | 42949672960 |     5000 |     5000 |  536870912000 |                2000 |
| 2023-05-26 15:47:15.523762 | 2023-05-26 15:47:15.523762 |           1008 | S4_unit_config            |      10 |      10 | 53687091200 | 53687091200 |     6000 |     6000 |  536870912000 |                2500 |
| 2023-05-29 16:34:04.176029 | 2023-05-29 16:34:04.176029 |           1009 | unit2                     |       5 |       5 | 10737418240 | 10737418240 |     1250 |     1250 |  128849018880 |               65535 |
+----------------------------+----------------------------+----------------+---------------------------+---------+---------+-------------+-------------+----------+----------+---------------+---------------------+
10 rows in set (0.00 sec)

MySQL [oceanbase]> CREATE RESOURCE POOL IF NOT EXISTS pool2
    -> unit = 'unit2',
    -> unit_num = 1,
    -> zone_list =('zone_1');
Query OK, 0 rows affected (0.02 sec)

MySQL [oceanbase]>

```

Previous

[IOPS 隔离](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000628793)

Next

[数据库租户 Unit 数从 4 扩展至 5 时卡住且新扩展的磁盘空间已满出现错误代码 -4184 的处理方法](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000003492892) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
