Mysql Auto Downtime ERROR: InnoDB: Cannot allocate memory for the buffer pool [Solved]

When I went to work this morning, I found that I couldn’t access the website built by WordPress. I reported the following error:

Error establishing a database connection

Quickly log on to your own Alibaba cloud server (centos7.4) to view the MySQL service. Through PS – EF | grep mysql, you find that there is no MySQL process

The first thing to do is to check the MySQL log and find the corresponding error exception through 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

It can be seen that there is not enough memory, resulting in the oom problem. Continue to view the memory with free – M and find the following:

free -m
              total        used        free      shared  buff/cache   available
Mem:            992         270         107          50         614         496
Swap:             0           0           0

There is not enough memory, only 107m space is available, swap free space is 0

So there are two solutions:

1: Modify the/etc/my.inf file to delete InnoDB_ buffer_ pool_ Size down

innodb_buffer_pool_size = 32M

2: Add swap file

For specific steps, see Adding swap swap space on CentOS 7

So far, the problem has been solved

—————————————–

There is no fear of problems, the solution is very important

Similar Posts: