HostOnNet Blog

InnoDB: mmap(x bytes) failed; errno 12

Looking for Linux Server Admin or WordPress Expert? We can help.

On a VPS, MariaDB refused to start with error

[root@ip-10-0-51-171 mariadb]# service mariadb start
Redirecting to /bin/systemctl start  mariadb.service
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
[root@ip-10-0-51-171 mariadb]# cat mariadb.log
170420 15:14:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170420 15:14:19 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 12689 ...
170420 15:14:19 InnoDB: The InnoDB memory heap is disabled
170420 15:14:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170420 15:14:19 InnoDB: Compressed tables use zlib 1.2.7
170420 15:14:19 InnoDB: Using Linux native AIO
170420 15:14:19 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137756672 bytes) failed; errno 12
170420 15:14:19 InnoDB: Completed initialization of buffer pool
170420 15:14:19 InnoDB: Fatal error: cannot allocate memory for the buffer pool
170420 15:14:19 [ERROR] Plugin 'InnoDB' init function returned error.
170420 15:14:19 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170420 15:14:19 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
170420 15:14:19 [Note] Plugin 'FEEDBACK' is disabled.
170420 15:14:19 [ERROR] Unknown/unsupported storage engine: InnoDB
170420 15:14:19 [ERROR] Aborting

170420 15:14:19 [Note] /usr/libexec/mysqld: Shutdown complete

170420 15:14:19 mysqld_safe mysqld from pid file /var/run/mariadb/ ended
[root@ip-10-0-51-171 mariadb]# 

This is because server can’t allocate more RAM for MySQL to run.

InnoDB: mmap(137756672 bytes) failed; errno 12

The problem is solved by adding a swap file.

dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile

Edit /etc/fstab

vi /etc/fstab


/swapfile swap swap defaults 0 0

Now edit /etc/my.cnf, set innodb_buffer_pool_size


Posted in MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.