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

[root@VM_0_7_centos /]# systemctl start mysqld.service
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。但是重装之后没多久又出现了这个错误,这个就有点问题了。找了很多资料,查看Mysql日志如下:

2019-07-09T01:23:01.592678Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.26) starting as process 28148 ...
2019-07-09T01:23:01.723338Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-07-09T01:23:01.723400Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-07-09T01:23:01.723406Z 0 [Note] InnoDB: Uses event mutexes
2019-07-09T01:23:01.723410Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-07-09T01:23:01.723413Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-07-09T01:23:01.723419Z 0 [Note] InnoDB: Using Linux native AIO
2019-07-09T01:23:01.750346Z 0 [Note] InnoDB: Number of pools: 1
2019-07-09T01:23:01.750538Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-07-09T01:23:01.770716Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-07-09T01:23:01.770839Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2019-07-09T01:23:01.770856Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-07-09T01:23:01.770866Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-07-09T01:23:01.770880Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-07-09T01:23:01.770887Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-07-09T01:23:01.782124Z 0 [ERROR] Failed to initialize builtin plugins.
2019-07-09T01:23:01.782151Z 0 [ERROR] Aborting

 根据一段一段错误信息查找问题时,网上基本上都是修改my.cnf配置文件,如修改innodb_buffer_pool_size的大小之类的,但是都没有作用。后面复制整段错误信息查找,找到了正确的解决方法。free指令查看内存:

[root@VM_0_7_centos /]# free
              total        used        free      shared  buff/cache   available
Mem:        1016516      722544       70124      108428      223848       37380
Swap:             0           0           0

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

[root@VM_0_7_centos /]# 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, 33.4362 s, 32.1 MB/s
[root@VM_0_7_centos /]# 
[root@VM_0_7_centos /]# sudo mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=8b3622a0-b64d-479a-a93a-75f0ba430e32
[root@VM_0_7_centos /]# 
[root@VM_0_7_centos /]# sudo swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[root@VM_0_7_centos /]# 
[root@VM_0_7_centos /]# free
              total        used        free      shared  buff/cache   available
Mem:        1016516      757720       67688       41652      191108       52000
Swap:       1048572       66752      981820
[root@VM_0_7_centos /]# 
[root@VM_0_7_centos /]# systemctl start mysqld.service
[root@VM_0_7_centos /]# 

问题解决!

感谢这篇文章:https://blog.csdn.net/qq_42262444/article/details/88524472

及原创文章:https://www.cnblogs.com/olinux/p/5144205.html

  • 9
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值