mysql报错mmap(137428992 bytes) failed; errno 12,Cannot allocate memory for the buffer pool

mysql以`systemctl start mysqld.service`的方式启动一段时间后发现突然无法启动,尝试重新启动也不能解决问题,排查问题时,先后通过`systemctl status mysqld.service`和`journalctl -xe` 命令查看问题,无所得.然后查看`/var/log/mysqld.log`发现日志内报错信息如下:

2019-02-07T00:33:21.731341Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 1
28M
2019-02-07T00:33:21.731439Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2019-02-07T00:33:21.731450Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-02-07T00:33:21.731464Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-02-07T00:33:21.731477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-02-07T00:33:21.731483Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-02-07T00:33:21.731489Z 0 [ERROR] Failed to initialize builtin plugins.
2019-02-07T00:33:21.731493Z 0 [ERROR] Aborting

网上查阅资料,有人说是 swap不够了,使用`free`命令查看发现空余swap确实为0,但很奇怪,我买的vultr和ecs使用`free`看到的空余的swap都是0,那么为什么vultr部署的mysql服务挂掉了,ecs的没有挂掉呢? 后来使用命令`sudo dd if=/dev/zero of=/swapfile bs=1M count=1024` 增加swap发现不起作用,我的空余swap仍然是0。

又查阅资料,有人说修改`my.cnf`里,将`innodb_buffer_pool_size` 注释打开,然后重启服务,发现还是报错.

后来将我的`my.cnf` 里的`innodb_buffer_pool_size= 64M`调低到64M,然后重启服务,mysql启动成功。

总结: 可能是我的服务器配置较低,使得mysql5.7正常的 `Initializing buffer pool=128`无法分配成功,降低其配置即可以。
`

猜你喜欢

转载自www.cnblogs.com/zhaowinter/p/10354620.html