mysql 自动宕机_Mysql自动宕机:InnoDB: Cannot allocate memory for the buffer pool

今天早上上班,发现自己使用wordpress搭建的网站不能访问,报如下错误:

Error establishing a database connection

赶紧登到自己阿里云服务器(centos7.4)查看mysql服务,通过ps -ef | grep mysql 发现已经没有了mysql进程。

首先要做的是查看mysql日志,通过vi /var/log/mysqld.log果然发现对应的错误异常:

2018-12-26T02:06:16.148626Z 0 [Note] Event Scheduler: Purging the queue. 0events"/var/log/mysqld.log" 623L,59293C2019-02-01T07:56:07.052989Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used formemory barrier2019-02-01T07:56:07.052991Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11

2019-02-01T07:56:07.052994Z 0[Note] InnoDB: Using Linux native AIO2019-02-01T07:56:07.053336Z 0 [Note] InnoDB: Number of pools: 1

2019-02-01T07:56:07.053443Z 0[Note] InnoDB: Using CPU crc32 instructions2019-02-01T07:56:07.055009Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size =128M2019-02-01T07:56:07.055061Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12

2019-02-01T07:56:07.055067Z 0 [ERROR] InnoDB: Cannot allocate memory forthe buffer pool2019-02-01T07:56:07.055073Z 0[ERROR] InnoDB: Plugin initialization aborted with error Generic error2019-02-01T07:56:07.055081Z 0 [ERROR] Plugin 'InnoDB' init function returned error.

2019-02-01T07:56:07.055085Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

2019-02-01T07:56:07.055088Z 0 [ERROR] Failed to initialize builtin plugins.

2019-02-01T07:56:07.055091Z 0[ERROR] Aborting2019-02-01T07:56:07.055108Z 0 [Note] Binlog end

2019-02-01T07:56:07.055159Z 0[Note] Shutting down plugin 'CSV'2019-02-01T07:56:07.055380Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

可见是内存不够用了,导致的oom问题。继续用free -m查看内存,发现如下:

free -m

total used free shared buff/cacheavailableMem: 992 270 107 50 614 496Swap:0 0 0

内存不够只有107M空间可用,swap可用空间为0。

所以解决方案有两个:

一:修改/etc/my.inf文件,将innodb_buffer_pool_size改小

innodb_buffer_pool_size = 32M

二:增加swap文件

至此问题解决。

-----------------------------------------

有问题不怕,解决思路很重要!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值