I'm running Graphite 0.9.12 on a Debian 7 server.
Recently I found errors in carbon-cache's log, saying "too many open files". According to carbon-cache's website, I need to increase nofile limit for carbon-cache. http://graphite.readthedocs.org/en/latest/carbon-daemons.html
So I increased both system wide and per-process limit:
cat /proc/sys/fs/file-max
5000000
And in /etc/security/limits.conf
* hard nofile 1000000
* soft nofile 1000000
root soft nofile 1000000
root hard nofile 1000000
www-data soft nofile 1000000
www-data hard nofile 1000000
Using ulimit command, I can confirm root/me/www-data's file limit has been increased.
I restarted carbon-cache multiple times. However, the per-process file limit for carbon-cache is not increased, still at 1024:4096
Max open files 1024 4096 files
I'm using /etc/init.d/carbon-cache start script to restart carbon-cache, sudo service carbon-cache restart
(or stop and then start)
The script is:
#!/bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: initscript for runit-managed carbon-cache service
### END INIT INFO
# Author: Opscode, Inc. <cookbooks@opscode.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="runit-managed carbon-cache"
NAME=carbon-cache
RUNIT=/usr/bin/sv
SCRIPTNAME=/etc/init.d/$NAME
# Exit if runit is not installed
[ -x $RUNIT ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
$RUNIT start $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
$RUNIT stop $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
status)
$RUNIT status $NAME && exit 0 || exit $?
;;
reload)
[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
$RUNIT reload $NAME
[ "$VERBOSE" != no ] && log_end_msg $?
;;
force-reload) ................ SO ON
Does anyone know how can I make carbon-cache apply my new nofile limit? Should I modify the start script or do something else?
===============================================================
Update:
I found another file may be related in my system. /etc/sv/carbon-cache/run
.
Originally, the content shows as:
#!/bin/sh
exec 2>&1
exec chpst -u www-data -l /opt/graphite/storage/carbon-cache.lock -- /opt/graphite/bin/carbon-cache.py --pid /opt/graphite/storage/carbon-cache-a.pid --debug start
I edited the file to:
#!/bin/sh
ulimit -n 999999
exec 2>&1
exec chpst -o 999999 -u www-data -l /opt/graphite/storage/carbon-cache.lock -- /opt/graphite/bin/carbon-cache.py --pid /opt/graphite/storage/carbon-cache-a.pid --debug start
Now in /proc/pid/limits, both soft and hard limit are 999999.