ERROR [InnoDB] mmap(137428992 bytes) failed; errno 12

Viewed 2861

The web application does not connect to the database on VDS (0.5 RAM, 1 core CPU). I can't understand the reason. I do not know what to do please tell me.

This is mysql configuration my.cnf. I included there innodb_buffer_pool_size = 250M

# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
max_connections=25
max_user_connections=20
wait_timeout=10
interactive_timeout=50
long_query_time=5
#log-queries-not-using-indexes
#log-slow-queries=/var/log/mysql/log-slow-queries.log

bind-address=185.231.154.57
#key_buffer = 16M
myisam_sort_buffer_size = 32M
join_buffer_size=1M
read_buffer_size=1M
sort_buffer_size=2M
#table_cache=1024
thread_cache_size=286
interactive_timeout=25
connect_timeout=5
max_allowed_packet=1M
max_connect_errors=1000
#query_cache_limit=1M
#query_cache_size=8M
#query_cache_type=1
tmp_table_size=16M

#innodb_use_native_aio = 0
innodb_buffer_pool_size = 250M
innodb_file_per_table

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid 

logs:

root@v101877:/home/servers/apache-tomee-plume-8.0.0-M1/binsystemctl status mysql
* mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-01-13 10:04:17 MSK; 10min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 681 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 642 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 681 (code=exited, status=1/FAILURE)
   Status: "SERVER_BOOTING"

Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.608676Z 0 [ERROR] [MY-012681] [InnoDB] mmap(137428992 bytes) failed; errno 12
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.610517Z 1 [ERROR] [MY-012956] [InnoDB] Cannot allocate memory for the buffer pool
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.610553Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.611113Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.612755Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.613398Z 0 [ERROR] [MY-010119] [Server] Aborting
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru mysqld[681]: 2019-01-13T07:04:17.626404Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.13)  MySQL Community Server - GPL.
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 13 10:04:17 v101877.hosted-by-vdsina.ru systemd[1]: Failed to start MySQL Community Server.
2 Answers

Suggestions to consider for your my.cnf [mysqld] section

# join_buffer_size=1M
# read_buffer_size=1M
# sort_buffer_size=2M
# table_cache=1024
# thread_cache_size=286
innodb_buffer_pool_size=10M

until you can get started. Yes, DISABLE all 5 of these lines so the DEFAULTS will allow you to get running.

If you have .5 G of RAM, expect FRUSTRATION. Very few people use less than 4 G of RAM at this point in time.

I'm using Vagrant with libvirt and I stumbled upon this error.

After hours of struggling, the problem has turned out to be the Vagrant configuration, instead of the mysql/mysqld one.

In the Vagrantfile I uncommented the option to customize the virtual machine's virtual RAM. The default was 512MB, with the 1024 value is working fine now:

config.vm.provider "libvirt" do |vb|
#   # Display the VirtualBox GUI when booting the machine
#   vb.gui = true
#
# Customize the amount of memory on the VM:
  vb.memory = "1024"
end

I hope it helps someone, I never had this error using Virtualbox, maybe it comes with a different default memory value out of the box.

Related