I have an Azure VM with CentOS 7.1, Apache 2.4.6, and MariaDB 5.5. The VM has 2 cores and 3.5 GB RAM. The server is only hosting a small WordPress site with almost no traffic.
For the past two days, MariaDB constantly crashes with an OOM error. I’ve tried so many different things for tweaking performance and so far absolutely nothing has helped. This is the current config from the
my.cnf
file:[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd performance_schema = off innodb_buffer_pool_size = 1024M key_buffer_size = 50M [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid
The Apache is a prefork version and I’ve added the following tweaks:
KeepAlive On KeepAliveTimeout 3 StartServers 1 MinSpareServers 3 MaxSpareServers 6 ServerLimit 24 MaxClients 24 MaxRequestsPerChild 3000
I’ve tried with the default settings too and it makes no difference. Here is a sampling of the errors from the MariaDB log:
160124 15:04:53 mysqld_safe Number of processes running now: 0 160124 15:04:53 mysqld_safe mysqld restarted 160124 15:05:47 [Note] /usr/libexec/mysqld (mysqld 5.5.44-MariaDB) starting as process 4014 ... 160124 15:05:47 InnoDB: The InnoDB memory heap is disabled 160124 15:05:47 InnoDB: Mutexes and rw_locks use GCC atomic builtins 160124 15:05:47 InnoDB: Compressed tables use zlib 1.2.7 160124 15:05:47 InnoDB: Using Linux native AIO 160124 15:05:48 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137756672 bytes) failed; errno 12 160124 15:05:48 InnoDB: Completed initialization of buffer pool 160124 15:05:48 InnoDB: Fatal error: cannot allocate memory for the buffer pool 160124 15:05:48 [ERROR] Plugin 'InnoDB' init function returned error. 160124 15:05:48 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 160124 15:05:48 [ERROR] mysqld: Out of memory (Needed 128917504 bytes) 160124 15:05:48 [ERROR] mysqld: Out of memory (Needed 96681984 bytes) 160124 15:05:48 [ERROR] mysqld: Out of memory (Needed 72499200 bytes) 160124 15:05:51 [Note] Plugin 'FEEDBACK' is disabled. 160124 15:05:52 [ERROR] Unknown/unsupported storage engine: InnoDB 160124 15:05:52 [ERROR] Aborting
What can I do? I have other VM’s in Azure with the same specs and running many more, and more complex, sites, and they have zero crashes.
EDIT This is what the memory looks like within one minute of starting up MariaDB:
[root@linuxvm admin]# systemctl start mariadb [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 670 2573 2 198 2577 Swap: 511 68 443 [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 1181 2052 2 207 2059 Swap: 511 64 447 [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 1523 1709 2 209 1715 Swap: 511 64 447 [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 1829 1397 2 214 1404 Swap: 511 64 447 [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 2713 506 2 222 515 Swap: 511 63 448 [root@linuxvm admin]# free -m total used free shared buff/cache available Mem: 3442 3206 93 2 143 59 Swap: 511 63 448
Answer
I’ll just put this here in case someone else needs it cause I literally just stumbled upon the answer now through trial and error, after an entire day of troubleshooting this issue. I read so many posts and blogs and none of them recommended adding the max_connections
directive to my.cnf
.
After adding the following lines, all my issues cleared up and MariaDB/MySQL stopped hogging all the memory. Your values may need to be adjusted for your specific scenario.
[mysqld]
max_connections = 50
innodb_buffer_pool_size = 1024M
Attribution
Source : Link , Question Author : blizz , Answer Author : blizz