Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I set ulimits for the mongod process/user on CentOS?

I've read the official documentation but it doesn't provide OS-specific instructions.

  • I need to set ulimit -u 64000 and need this to persist after reboot.

  • I'm running CentOS 5.5 although will be upgrading to 6.5 soon.

  • I'd prefer not to modify any scripts installed by the package manager

share|improve this question
up vote 4 down vote accepted

Modify /etc/security/limits.conf with what you need. Example:

user soft nproc 64000

This line will set the number of processors (-u) to 64000 for "user". Soft/hard limits can be the same (soft allows spikes while hard prevents spawning).

share|improve this answer
Thanks, but after doing this and restarting mongod cat /proc/{pid}/limits shows no change. Does something additional need to be done to ensure the conf is read? – Tim Apr 28 '14 at 17:07
Yes, reboot the server. It's set by the kernel. – Nathan C Apr 28 '14 at 17:49
Ah, many thanks! – Tim Apr 29 '14 at 11:25

The newer version of the CentOS mongod startup script (/etc/init.d/mongod) has the default settings built into the start option:

  # Recommended ulimit values for mongod or mongos
  # See
  ulimit -f unlimited
  ulimit -t unlimited
  ulimit -v unlimited
  ulimit -n 64000
  ulimit -m unlimited
  ulimit -u 32000

  echo -n $"Starting mongod: "
  daemon --user "$MONGO_USER" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod

If you want to change the values and not modify the script, copy the script to /etc/init.d/mongod-custom, then edit the custom init script, set your values and change chkconfig to use mongod-custom instead of mongod.

share|improve this answer

Make this change in the /etc/security/limits.conf file. Set the hard and soft limits, and you should be good.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.