I've got a MongoDB server that runs out of file descriptors for open connections. I changed the settings in /etc/security/limits.conf so that every user gets a hard and soft limit of 65000 of open files and added session require pam_limits.so to /etc/pam.d/su, common-session, common-session-noninteractive, sshd. Server was restarted after changes made.
Afterwards, ulimit -a yields the desired result of having 65000 max file descriptors. Curiously though, while every process that gets started for any particular user uses the new file descriptor max of 65000, any MongoDB process that starts up (no matter the user) still only gets 1024 max file descriptors. I even tried opening a text file as the mongodb user, and that uses the 65000 limit.
System:
- Ubuntu Maverick
- MongoDB 1.6.5
I am using an upstart script to start the MongoDB instance, which is here:
pre-start script
PORT=27027
mkdir -p /var/lib/mongodb${PORT}
mkdir -p /var/log/mongodb
limit nofile 65000 65000
limit nproc 65000 65000
end script
start on runlevel [2345]
stop on runlevel [06]
script
PORT=27027
ENABLE_MONGODB="yes"
if [ -e /var/lib/mongodb${PORT}/mongod.lock ]; then rm /var/lib/mongodb${PORT}/mongod.lock; fi
if [ ! -d /var/lib/mongodb${PORT} ]; then mkdir -p /var/lib/mongodb${PORT}; fi
chown -R mongodb:mongodb /var/lib/mongodb${PORT}
if [ "x$ENABLE_MONGODB" = "xyes" ]; then
exec start-stop-daemon --start --quiet --chuid mongodb \
--pidfile /var/lib/mongodb${PORT}/${PORT}.pid \
--exec /usr/bin/mongod -- \
--port ${PORT} \
--dbpath /var/lib/mongodb${PORT} \
--logpath /var/log/mongodb/mongodb${PORT}.log \
--logappend \
--maxConns = 50000 \
--replSet oascluster \
--oplogSize 200 \
--rest
fi
end script
respawn
respawn limit 20 30
Am I missing a setting somewhere?