现象
在创建资源池时,或者在调整资源池资源规格时,遇到报错,信息如下:
ERROR 4624 (HY000): machine resource 'zone1' is not enough to hold a new unit
原因
报错信息提示某个 Zone 没有足够的资源创建该资源单元。
出现该报错通常是资源单元规格超出了集群资源可用资源。所以创建资源池或者调整资源池之前需要计算集群可用资源。
解决方法
您可通过查看视图 __all_virtual_server_stat
了解集群剩余可用资源。 由于默认 sys 租户的资源规格的 min_cpu
和 min_memory
与对应的 max_cpu
和 max_memory
不一致,所以集群剩余资源的展示将会不准确。
查看剩余资源的 SQL:
select a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, cpu_assigned, (cpu_total-cpu_assigned) cpu_free, mem_total/1024/1024/1024 mem_total_gb, mem_assigned/1024/1024/1024 mem_assign_gb, (mem_total-mem_assigned)/1024/1024/1024 mem_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
;
以上 SQL 的查询结果是四舍五入的。如果所有资源的分配采用整数,则查询结果为准确结果。
现象
使用普通的建表语句,遇到报错,提示机器资源不足。
MySQL [test]> create table t01(id bigint not null primary key auto_increment, c1 varchar(50), c2 datetime not null default current_timestamp);
ERROR 4624 (HY000): machine resource is not enough to hold a new unit
原因
在三副本集群里,默认建表时会创建三个副本。如果有节点掉线,并且该租户在掉线的节点上还有资源单元(resource unit
)存在,则这个建表语句就无法创建三个副本。默认情况下,OceanBase 数据库为了保证表元数据强一致,就会报错。
这个报错信息跟机器资源有关,但又不是那么直接。可以通过修改租户参数(ob_create_table_strict_mode
)关闭这个强约束。
解决方法
方法一:找出租户的资源单元所在节点,查看该节点掉线的原因,解决它,然后建表。这个时间可能有点长。
方法二:会话级别或者全局级别关闭参数 ob_create_table_strict_mode
,允许节点掉线情况下建表能成功。
MySQL [test]> show global variables like '%strict%';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| ob_create_table_strict_mode | ON |
+-----------------------------+-------+
1 row in set (0.009 sec)
MySQL [test]> set session ob_create_table_strict_mode=off;
Query OK, 0 rows affected (0.001 sec)
MySQL [test]> create table t01(id bigint not null primary key auto_increment, c1 varchar(50), c2 datetime not null default current_timestamp);
Query OK, 0 rows affected (0.071 sec)
MySQL [test]> desc t01;
+-------+-------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+-------------------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| c1 | varchar(50) | YES | | NULL | |
| c2 | datetime | NO | | CURRENT_TIMESTAMP | |
+-------+-------------+------+-----+-------------------+----------------+
3 rows in set (0.011 sec)
节点异常要尽快修复。方法二理论上存在风险。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。