MySQL 启动提示 Cannot allocate memory for the buffer pool
2019-09-16 00:00
1621 查看
环境:
CentOS 7.2 + MySQL 5.7.26
故障:
在一台总物理内存125G的服务器上,修改mysql的innodb_buffer_pool_size为64G后,启动报错,截图如下:
错误原因大致是内存不足。
诊断
开始以为是调优参数设置问题,仔细参阅官网后,未发现任何问题;试着将innodb_buffer_pool_size调整为60G,数据库可以正常启动,因此怀疑是操作系统限制了内存分配。通过排查发现该操作系统的/proc/sys/vm/overcommit_memory值为2,而默认值应该是0。overcommit_memory是一个内核对内存分配的一种策略,仔细参阅了该参数,大致定义如下:
overcommit_memory=0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
overcommit_memory=1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
overcommit_memory=2, 表示内核允许分配超过所有物理内存和交换空间总和的内存。
当overcommit_memory=2的时候,它一般是代表的是系统中总的内存的百分比,具体的虚拟内存总和为:
内存总和=SwapTotal + MemTotal * overcommit_ratio,这里的 overcommit_ratio默认为50%。
解决方案
通过上面诊断以后,解决方案就是修改 /proc/sys/vm/overcommit_memory为0:
echo 0 > /proc/sys/vm/overcommit_memory
修改完成后,再次启动mysql,此时能够正常启动。
相关文章推荐
- mysql:failed,启动失败,mmap failed-Cannot allocate memory for the buffer pool
- mysql无法启动——cannot allocate the memory for the buffer pool
- mysql启动报错【InnoDB: Cannot allocate memory for the buffer pool】
- Mysql cannot allocate memory for the buffer pool 解决方法
- mysql错误日志之cannot allocate the memory for the buffer pool
- 解决MySQL : InnoDB: Cannot allocate memory for the buffer pool
- [MYSQL] ERROR: cannot allocate the memory for the buffer pool
- 安装mysql 报Fatal error: cannot allocate memory for the buffer pool
- MySQL:cannot allocate the memory for the buffer pool
- Cannot allocate memory for the buffer pool
- 【数据库】InnoDB: Fatal error: cannot allocate memory for the buffer pool
- Fatal error: cannot allocate memory for the buffer pool
- Fatal error: cannot allocate memory for the buffer pool
- InnoDB: Cannot allocate memory for the buffer pool
- InnoDB: Cannot allocate memory for the buffer pool
- [ERROR] InnoDB: Cannot allocate memory for the buffer pool
- mysql报错mmap(137428992 bytes) failed; errno 12,Cannot allocate memory for the buffer pool
- centos中启动MySQL提示Job for mysqld.service failed because the control process exited with error code.
- Centos7启动mysql5.6 提示ERROR! The server quit without updating PID file (/var/lib/mysql/XXX.pid).
- Tomcat 启动报错 : There is insufficient memory for the Java Runtime Environment to continue.