首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何提高Debian 7上的碳缓存nofile限制?

如何提高Debian 7上的碳缓存nofile限制?
EN

Stack Overflow用户
提问于 2016-01-04 23:21:58
回答 1查看 1.1K关注 0票数 0

我正在Debian 7服务器上运行Graphite 0.9.12。

最近我在碳缓存的日志中发现了错误,说“打开的文件太多了”。根据碳缓存的网站,我需要增加碳缓存的无文件限制。http://graphite.readthedocs.org/en/latest/carbon-daemons.html

因此,我增加了系统范围和每个进程的限制:

代码语言:javascript
复制
cat /proc/sys/fs/file-max
5000000

和/etc/security/limits.conf .

代码语言:javascript
复制
* 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。

代码语言:javascript
复制
Max open files            1024                 4096                 files

我使用/etc/init.d/碳缓存启动脚本重新启动碳缓存,sudo service carbon-cache restart (或停止,然后启动)

剧本是:

代码语言:javascript
复制
#!/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

最初,内容显示为:

代码语言:javascript
复制
#!/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

我编辑了该文件如下:

代码语言:javascript
复制
#!/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。

EN

回答 1

Stack Overflow用户

发布于 2016-01-04 23:51:44

使用ulimit命令,您可以更改当前shell环境的软限制,如果以root用户身份运行,则更改硬限制。

D中的脚本从新的shell env (会话)开始,必须再次应用ulimit。您可以在/etc/init.d/carbon-cache语句之前添加case语句,如下所示:

代码语言:javascript
复制
ulimit -n 999999

这将为当前(init.d start)会话设置新的限制,每次启动/重新启动/重新加载/任何东西。限制从父进程继承到其子进程,因此碳缓存也会受到影响。

编辑

  1. ulimit -H设置硬限制
  2. 是主管吗?如果是这样的话,也可以在小飞碟部分的/etc/supervisor/supervisord.conf中添加[supervisord]

minfds=10000

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34601678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档