I need to do something like this to run MongoDB
$numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf &
What should I change to be able to run the mongo daemon with the options above?
It depends from how you are managing your services.
run program will in essence boil down to
#!/bin/nosh chdir / setuidgid mongodb mongod
This is in fact the very basic MongoDB
run program that comes in the regular services bundle of my nosh suite, which doesn't use a shell as a script interpreter. shell-interpreted
run scripts for daemontools-managed services like the one used by contegix or Yoshiaki Kawazu's one may look more complex but all end up having an
exec setuidgid mongodb mongod command somewhere, even if it is hidden behind shell variable expansions.
With daemontools-family service managers,
run programs such as these are in essence simple sequences of chain-loading commands. The
numactl program is a chain-loading command too, that modifies settings of its own process then chains to a program named on its command line. It fits right in with daemontools tools such as
So you just add
numactl into the chain there, which would be
#!/bin/nosh chdir / numactl --interleave=all -- setuidgid mongodb mongodin a nosh script or
exec \ numactl --interleave=all -- \ setuidgid mongodb \ mongodin a shell script. (In a shell script, you can make the script try to auto-detect the presence of
numactl. Just nick the mechanism from the upstart folk, below.)
Then just restart the service with (nosh only)
system-control condrestart mongod.serviceor with
svc -t /service/mongodbif you are using the old conventional daemontools
mongod.service unit file there will be a section that has
[Service] User=mongodb ExecStart=/usr/local/bin/mongod $OPTIONS run
This is what you will find in the systemd service unit that comes supplied with mongodb, which is slightly but not much more complex.
So you just do as you suggested and modify the
ExecStart=/usr/bin/numactl --interleave=all -- /usr/local/bin/mongod $OPTIONS run
Either put this in a replacement
/etc/systemd/service/mongod.service unit file to completely override the package-supplied unit file, or retain the package-supplied unit file and use an override for just that setting in (say)
Then just reload the service unit from file(s) with
systemctl daemon-reloadand restart the service with
systemctl condrestart mongod.service
The answers at https://askubuntu.com/questions/293468/ over on AskUbuntu are approaching 2 years old, now. In the meantime,
numactl capability has been placed into the package-supplied upstart job file.
So your system, presuming that it is up to date, should already be doing this and you shouldn't even need a
initctl restart mongodb