码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-02-13 10:43:08      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:rri   shared   buffer   zlib   tin   ota   sha   通过   方案   

今天早上上班,发现自己使用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. 0 events
"/var/log/mysqld.log" 623L, 59293C
2019-02-01T07:56:07.052989Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-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 AIO
2019-02-01T07:56:07.053336Z 0 [Note] InnoDB: Number of pools: 1
2019-02-01T07:56:07.053443Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-02-01T07:56:07.055009Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-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 for the buffer pool
2019-02-01T07:56:07.055073Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-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] Aborting

2019-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/cache   available
Mem:            992         270         107          50         614         496
Swap:             0           0           0

 

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

 

所以解决方案有两个:

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

innodb_buffer_pool_size = 32M

 

 

二:增加swap文件

具体步骤参见:在CentOS 7上添加Swap交换空间

 

至此问题解决。

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

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

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

标签:rri   shared   buffer   zlib   tin   ota   sha   通过   方案   

原文地址:https://www.cnblogs.com/rocly/p/10368368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!