From: Reindl Harald Date: April 13 2012 2:35pm Subject: Re: FYI: how to prevent mysql from oom-killer List-Archive: http://lists.mysql.com/mysql/227192 Message-Id: <4F8839BC.5090805@thelounge.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig217147D52D6FFFB10311EBBE" --------------enig217147D52D6FFFB10311EBBE Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable hm - my servers generally have no swap or better said only a 500 MB swap-file, they are all virtual machines in a ESXi cluster you really do not want a VM swapping this leads in unusaeable performance in my case the problem was another process eating up all memory by user-mistake and my hint is to make sure in this case that this process get killed and never mysqld but i never ever had to reboot any linux guest to get it back to life Am 13.04.2012 16:27, schrieb Johnny Withers: > I had this same problem with the OOM for a while. Very frustrating to h= ave to reboot a server to bring it back to life. >=20 > I found out the OOM only ran when the swap file was about 99% full. The= servers I had this problem on had 16GB and > 24GB of ram, but only 2GB of swap. I increased the swap on the 24GB ser= vers to 48GB and on the 16GB servers to > 32GB. The swap never fills to over 60% now and I haven't' had any OOM p= roblems since and the systems run great. >=20 > I've also set vm.swappiness=3D0 in /etc/sysctl.conf >=20 > -JW >=20 > On Fri, Apr 13, 2012 at 7:17 AM, Reindl Harald > wrote: >=20 > the following may be useful for most server systems >=20 > OOM-killer acts if some process reclaims more and more > memory and the kernel randomly kills unimportant tasks > using hughe memory >=20 > 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 > _________________________________________ >=20 > 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 >=20 > i am considering include this in "mysqld.service" as > "ExecStartPost=3D-/usr/local/bin/mysql-no-oom.sh" in our > internal mysqld-packages and include also the script > _________________________________________ >=20 > [root@mail:~]$ cat /etc/crontab | grep oom > 0,15,30,45 * * * * root bash /usr/local/bin/mysql-no-oom.sh >=20 > [root@mail:~]$ cat /usr/local/bin/mysql-no-oom.sh > #!/bin/bash > pgrep -f "/usr/libexec/mysqld" | while read PID; do echo -1000 > /p= roc/$PID/oom_score_adj; done >=20 >=20 >=20 >=20 > --=20 > ----------------------------- > Johnny Withers > 601.209.4985 > johnny@stripped --------------enig217147D52D6FFFB10311EBBE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+IObwACgkQhmBjz394AnmtiACfdmpv9cu0mQJxvTW4qE4WLMt5 oN4An1mBxV5WrJHKioO6IpSf3TqFdu3t =TSOB -----END PGP SIGNATURE----- --------------enig217147D52D6FFFB10311EBBE--