创建资源池失败

Database changed
MySQL [oceanbase]> select zone,cpu_total,cpu_assigned,round(mem_total/1024/1024/1024,2) MEM_TOTAL_GB,round(mem_assigned/1024/1024/1024,2) MEM_ASSIGNED_GB FROM __ALL_VIRTUAL_SERVER_STAT;
±------±----------±-------------±-------------±----------------+
| zone | cpu_total | cpu_assigned | MEM_TOTAL_GB | MEM_ASSIGNED_GB |
±------±----------±-------------±-------------±----------------+
| zone1 | 14 | 2.5 | 16.00 | 4.00 |
±------±----------±-------------±-------------±----------------+
1 row in set (0.003 sec)

MySQL [oceanbase]> CREATE RESOURCE UNIT unit1 MAX_CPU 2, MAX_MEMORY ‘2G’, MAX_IOPS 10000,MAX_DISK_SIZE ‘500G’, MAX_SESSION_NUM 1000, MIN_CPU=2, MIN_MEMORY=‘2G’,MIN_IOPS=1000;
Query OK, 0 rows affected (0.009 sec)

MySQL [oceanbase]> SELECT * FROM oceanbase.__all_unit_config\G;
*************************** 1. row ***************************
gmt_create: 2023-09-27 17:17:13.230572
gmt_modified: 2023-09-27 17:17:13.230572
unit_config_id: 1
name: sys_unit_config
max_cpu: 5
min_cpu: 2.5
max_memory: 5153960755
min_memory: 4294967296
max_iops: 10000
min_iops: 5000
max_disk_size: 53659828224
max_session_num: 9223372036854775807
*************************** 2. row ***************************
gmt_create: 2023-09-27 17:51:53.055953
gmt_modified: 2023-09-27 17:51:53.055953
unit_config_id: 1001
name: unit1
max_cpu: 2
min_cpu: 2
max_memory: 2147483648
min_memory: 2147483648
max_iops: 10000
min_iops: 1000
max_disk_size: 536870912000
max_session_num: 1000
2 rows in set (0.002 sec)

ERROR: No query specified

MySQL [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 10, MAX_MEMORY ‘16G’, MAX_IOPS 128,max_disk_size ‘100G’, MAX_SESSION_NUM 64, MIN_CPU=10, MIN_MEMORY=‘8G’,MIN_IOPS=128;
Query OK, 0 rows affected (0.002 sec)

MySQL [oceanbase]> CREATE RESOURCE POOL pool1 UNIT=‘unit1’,UNIT_NUM=1,ZONE_LIST=(‘zone1’);
ERROR 4624 (HY000): machine resource ‘zone1’ is not enough to hold a new unit
MySQL [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 10, MAX_MEMORY ‘8G’, MAX_IOPS 128,max_disk_size ‘100G’, MAX_SESSION_NUM 64, MIN_CPU=10, MIN_MEMORY=‘8G’,MIN_IOPS=128;
Query OK, 0 rows affected (0.002 sec)

MySQL [oceanbase]> CREATE RESOURCE POOL pool1 UNIT=‘unit1’,UNIT_NUM=1,ZONE_LIST=(‘zone1’); ERROR 4624 (HY000): machine resource ‘zone1’ is not enough to hold a new unit
MySQL [oceanbase]>

啥版本

3.1.3

sys_Unit的 ,自定义的租户规格里的 min_cpu 跟 max_cpu 、min_memory跟 max_memory 都拉平。
精确计算还剩余多少cpu和mem 可以分配。

MySQL [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 10, MAX_MEMORY ‘8G’, MAX_IOPS 128,max_disk_size ‘100G’, MAX_SESSION_NUM 64, MIN_CPU=10, MIN_MEMORY=‘8G’,MIN_IOPS=128;
Query OK, 0 rows affected (0.002 sec)

MySQL [oceanbase]> CREATE RESOURCE POOL pool1 UNIT=‘unit1’,UNIT_NUM=1,ZONE_LIST=(‘zone1’); ERROR 4624 (HY000): machine resource ‘zone1’ is not enough to hold a new unit
MySQL [oceanbase]>

MAX和MIN都是相等的

看下面sql:

select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free
, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024,2) mem_free_gb
, round(disk_total/1024/1024/1024) disk_total_gb, round((disk_total-disk_assigned)/1024/1024/1024) disk_free_gb
from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
order by a.zone, a.svr_ip
;

select t1.name resource_pool_name,  t2.`name` unit_config_name, t2.max_cpu, t2.min_cpu
, round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb
, round(t2.max_disk_size/1024/1024/1024) max_disk_size , t4.tenant_name
from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
    join __all_unit t3 on (t1.`resource_pool_id` = t3.`resource_pool_id`)
    left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
order by t1.`resource_pool_id`, t2.`unit_config_id`, t3.unit_id
;

MySQL [oceanbase]> select a.zone,concat(a.svr_ip,’:’,a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free
→ , round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024,2) mem_free_gb
→ , round(disk_total/1024/1024/1024) disk_total_gb, round((disk_total-disk_assigned)/1024/1024/1024) disk_free_gb
→ from __all_virtual_server_stat a join __all_server b on (a.svr_ip=b.svr_ip and a.svr_port=b.svr_port)
→ order by a.zone, a.svr_ip
→ ;
±------±---------------±----------±---------±-------------±------------±--------------±-------------+
| zone | observer | cpu_total | cpu_free | mem_total_gb | mem_free_gb | disk_total_gb | disk_free_gb |
±------±---------------±----------±---------±-------------±------------±--------------±-------------+
| zone1 | 127.0.0.1:2882 | 14 | 11.5 | 16 | 12.00 | 50 | 0 |
±------±---------------±----------±---------±-------------±------------±--------------±-------------+
1 row in set (0.006 sec)

MySQL [oceanbase]> select t1.name resource_pool_name, t2.name unit_config_name, t2.max_cpu, t2.min_cpu
→ , round(t2.max_memory/1024/1024/1024) max_mem_gb, round(t2.min_memory/1024/1024/1024) min_mem_gb
→ , round(t2.max_disk_size/1024/1024/1024) max_disk_size , t4.tenant_name
→ from __all_resource_pool t1 join __all_unit_config t2 on (t1.unit_config_id=t2.unit_config_id)
→ join __all_unit t3 on (t1.resource_pool_id = t3.resource_pool_id)
→ left join __all_tenant t4 on (t1.tenant_id=t4.tenant_id)
→ order by t1.resource_pool_id, t2.unit_config_id, t3.unit_id
→ ;
±-------------------±-----------------±--------±--------±-----------±-----------±--------------±------------+
| resource_pool_name | unit_config_name | max_cpu | min_cpu | max_mem_gb | min_mem_gb | max_disk_size | tenant_name |
±-------------------±-----------------±--------±--------±-----------±-----------±--------------±------------+
| sys_pool | sys_unit_config | 5 | 2.5 | 5 | 4 | 50 | sys |
±-------------------±-----------------±--------±--------±-----------±-----------±--------------±------------+
1 row in set (0.005 sec)

MySQL [oceanbase]>

sys_unit_config 的 min_cpu max_cpu 和 min_memory max_memory 没有拉平,会影响对剩余资源的计算。

另外,发帖时使用 markdown 语法,可以将sql 放到 引用里,格式好看一些。