Starting MongoDB on CentOS with NUMA disabled

This may not be the best way to do this but it works for me. I got fed up with seeing the following message in the logs every time MongoDB was restarted.*

Wed Aug  1 12:06:39 [initandlisten] ** WARNING: You are running on a NUMA machine.
Wed Aug  1 12:06:39 [initandlisten] *          We suggest launching mongod like this to avoid performance problems:
Wed Aug  1 12:06:39 [initandlisten] *
              numactl –interleave=all mongod [other options]

I’m using a pretty boilerplate init.d script for mongo so I figured it would be simple to update the start command to use numactl. What I discovered is that my init script uses a builtin bash function called daemon to start the mongo process. daemon allows for a –user option. Unfortunately, numactl does not. Neither is it possible to execute a bash function using numactl. “TO THE GOOGLES!”

Hmm, everything I see recommends wrapping the numactl command around another command called start-stop-daemon. OK, but CentOS doesn’t have a start-stop-daemon command. Argh.

Finally I resorted to digging into the daemon function to see what it was doing and came up with this:

numactl --interleave=all runuser -s /bin/bash $MONGO_USER -c "$mongod $MONGO_OPTS"

It works. Moving on now.

Written on August 1, 2012