我正在Debian 7服务器上运行Graphite 0.9.12。
最近我在碳缓存的日志中发现了错误,说“打开的文件太多了”。根据碳缓存的网站,我需要增加碳缓存的无文件限制。http://graphite.readthedocs.org/en/latest/carbon-daemons.html
因此,我增加了系统范围和每个进程的限制:
cat /proc/sys/fs/file-max
5000000和/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使用ulimit命令,我可以确认root/me/www-数据的文件限制已经增加了。
我多次重新启动碳缓存。然而,碳缓存的每个进程文件限制没有增加,仍然是1024:4096。
Max open files 1024 4096 files我使用/etc/init.d/碳缓存启动脚本重新启动碳缓存,sudo service carbon-cache restart (或停止,然后启动)
剧本是:
#!/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有人知道我怎样才能让碳缓存应用到我的新的文件限制吗?我应该修改开始脚本还是做其他事情?
===============================================================
更新:
我发现另一个文件可能与我的系统有关。/etc/sv/carbon-cache/run。
最初,内容显示为:
#!/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我编辑了该文件如下:
#!/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现在在/proc/pid/limits中,软限制和硬限制都是999999。
发布于 2016-01-04 23:51:44
使用ulimit命令,您可以更改当前shell环境的软限制,如果以root用户身份运行,则更改硬限制。
D中的脚本从新的shell env (会话)开始,必须再次应用ulimit。您可以在/etc/init.d/carbon-cache语句之前添加case语句,如下所示:
ulimit -n 999999这将为当前(init.d start)会话设置新的限制,每次启动/重新启动/重新加载/任何东西。限制从父进程继承到其子进程,因此碳缓存也会受到影响。
编辑
ulimit -H设置硬限制/etc/supervisor/supervisord.conf中添加[supervisord]。minfds=10000
https://stackoverflow.com/questions/34601678
复制相似问题