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.

Published by

Simon J Mudd

Born in England, I now live in Spain. I spent a few years living in the Netherlands. I've worked in banking (financial markets) both in IT and as a broker, but IT has always had a stronger influence. Now working at booking.com as a Database Administrator. Other interests include photography, ham radio (not active lately). Married and with two children, living happily in Madrid.

4 thoughts on “How to start mysqld using numactl”

  1. 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.

Leave a Reply