FYI: how to prevent mysql from oom-killer

Reindl Harald h.reindl at thelounge.net
Fri Apr 13 12:17:10 UTC 2012


the following may be useful for most server systems

OOM-killer acts if some process reclaims more and more
memory and the kernel randomly kills unimportant tasks
using hughe memory

in case of a running mysqld the classification "unimportant"
is nearly all time wrong and can cause hughe damage and work
in other words: you really never want killed a database server
randomly instead "dbmail-imapd" which can be restarted via
systemd without pain and may be the root-cause of OOM
_________________________________________

with one single command you can protect processes from get killed
i started to run this every 15 minutes to make sure it is also
active after restarts

i am considering include this in "mysqld.service" as
"ExecStartPost=-/usr/local/bin/mysql-no-oom.sh" in our
internal mysqld-packages and include also the script
_________________________________________

[root at mail:~]$ cat /etc/crontab | grep oom
0,15,30,45 * * * * root bash /usr/local/bin/mysql-no-oom.sh

[root at mail:~]$ cat /usr/local/bin/mysql-no-oom.sh
#!/bin/bash
pgrep -f "/usr/libexec/mysqld" | while read PID; do echo -1000 > /proc/$PID/oom_score_adj; done

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.fedoraproject.org/pipermail/users/attachments/20120413/aff7f805/attachment.sig>


More information about the users mailing list