Mysql启动失败:InnoDB: mmap(137428992 bytes) failed; errno 12

2022-12-05 13:59:10 浏览数 (1)

[root@iZwz98m7yqiqoatk3bc39fZ ~]# systemctl start mysqld

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

linux服务器上Mysql启动报错,找了很多资料,查看Mysql日志如下:

[root@iZwz98m7yqiqoatk3bc39fZ ~]# tail -200f /var/log/mysqld.log

2022-03-25T18:15:52.462587Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12

2022-03-25T18:15:52.462593Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool

2022-03-25T18:15:52.462599Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error

2022-03-25T18:15:52.462608Z 0 [ERROR] Plugin 'InnoDB' init function returned error.

2022-03-25T18:15:52.462613Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2022-03-25T18:15:52.462618Z 0 [ERROR] Failed to initialize builtin plugins.

2022-03-25T18:15:52.462623Z 0 [ERROR] Aborting

最后找到了正确的解决方法。free指令查看内存:

[root@iZwz98m7yqiqoatk3bc39fZ ~]# free

total used free shared buff/cache available

Mem: 498432 230928 117024 528 150480 253864

Swap: 0 0 0

服务器没有配置Swap分区,关于Swap分区可以参见百度百科(Swap分区),知道了当前问题的源头就给机器配置一个Swap分区大小1G

[root@iZwz98m7yqiqoatk3bc39fZ ~]# sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

1024 0 records in

1024 0 records out

1073741824 bytes (1.1 GB) copied, 9.10677 s, 118 MB/s

[root@iZwz98m7yqiqoatk3bc39fZ ~]# sudo mkswap /swapfile

Setting up swapspace version 1, size = 1048572 KiB

no label, UUID=7e142fa1-3db5-4e5f-9025-8a52166e9ee1

[root@iZwz98m7yqiqoatk3bc39fZ ~]# sudo swapon /swapfile

swapon: /swapfile: insecure permissions 0644, 0600 suggested.

[root@iZwz98m7yqiqoatk3bc39fZ ~]# free

total used free shared buff/cache available

Mem: 498432 231512 5884 528 261036 253296

Swap: 1048572 0 1048572

[root@iZwz98m7yqiqoatk3bc39fZ ~]# systemctl start mysqld.service

问题解决!

0 人点赞