Increase locked memory limit with ulimit -l
Read bellow to see more details about this approach:
I have this problem with docker. On this specific server, we run more than 100 containers and about 30 MySQL containers.
After a long search and trying some things I see that the problem is related to having many docker containers, but I did not find any limit.
Even with no volumes the error appears, so nothing related to having some file in the directory.
After 3 days, I test replace MySQL with the MariaDB image, and finally, we have a decent message for the error.
The logs say that InnoDB can't be initialized because the system does not have a sufficient memory-locked limit. A system limit that can be read or set with limit -l
.
Ps: To keep ulimit settings after restart, edit /etc/security/limits.conf
file.
So, after that, I increase the limit to double the current value and receive now a more clear log from MySQL with the message:
Cannot initialize AIO sub-system
After that, I have to increase the aio-max-nr
value from the system.
To read the current value of aio-max-nr
, execute cat /proc/sys/fs/aio-max-nr
.
To set a new value, execute: sudo sysctl -w fs.aio-max-nr=524288
and to keep the value when restarting, edit the /etc/sysctl.conf
with the new value.
After editing these settings you will run the MySQL container again. But remember, now you have to reset or clear the /var/lib/mysql folder to run without the first error.