How to start mysqld using numactl

Various people have complained about Linux swapping unexpectedly on boxes running mysqld, when apparently mysqld was not using all the memory and there was quite a bit of free memory available.

There’s also an article by Jeremy Cole. However, his solution requires a one-line change to mysqld_safe which while it’s small does not work very well if you have to maintain a large number of servers and are using packages asa package upgrade will overwrite the modified file mysqld_safe and then restart mysqld with the unmodified script. This leads to the need to repatch the script and then restart mysqld. Not very helpful.

So I was looking for another solution and came up with this option which basically requires a minor change to /etc/my.cnf and the use of a small shell wrapper script. The change to my.cnf is simply to add the following to the [mysqld_safe] section:

The wrapper script is little more than:

This minor change means that you can still use the standard mysql scripts and they will work even after an upgrade to a new rpm or other type of package. So if you’ve seen your mysql server swapping when you think you have the memory settings correctly adjusted and have been trying to figure out how to easily adjust the configuration to try out numactl to see if this improves things this seems to be an easier way of doing it.

Tags: , , ,

4 Responses to “How to start mysqld using numactl”

  1. Is there a bug report or worklog for inclusion in MySQL/MariaDB?

  2. Simon J Mudd says:

    Hi Daniël,

    I did open a ticket with Oracle support about this but the ticket was completely internal. The only thing that would be needed to include this in either MariaDB or MySQL would be the wrapper script and I´m not sure that it´s worth including this in binary packages as there may be minor differences due to knowing how to find the numactl script and of course if indeed the system is running Linux or not.

    So I´ve not pursued this further.

  3. […] erweitert, so daß es den Output von /proc/<mysqld>/numa_maps archivieren läßt, um besser debuggen zu können, dann bekommt man spontane Connection Timeouts in einem Ausmaß, das […]

  4. Staffan says:

    Thx Simon, great stuff, deploying it in production right now :)

Leave a Reply