我在 Ubuntu 10.04 64 位上运行 Squid 2.7。我遇到了 Squid 耗尽文件描述符的问题,/var/log/squid/cache.log 中显示以下错误:
警告!您的缓存已用完文件描述符
我检查过:
鱿鱼客户端经理:信息 | grep '文件描述'
它显示我只有 1024 个可用的文件描述符。
我更改了 /etc/security/limits.conf,在末尾添加了以下内容:
* soft nofile 32768
* hard nofile 32768
proxy soft nofile 32768
proxy hard nofile 32768
Run Code Online (Sandbox Code Playgroud)
将其添加到 /etc/squid/squid.conf 中:
max_filedescriptors 32768
Run Code Online (Sandbox Code Playgroud)
还更改了/etc/default/squid:
SQUID_MAXFD=32768
Run Code Online (Sandbox Code Playgroud)
什么都没有解决。最后我编辑/etc/init.d/squid添加“ulimit -n 32768”:
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
ulimit -n 32768
<... snipped ...>
Run Code Online (Sandbox Code Playgroud)
成功了!:)
我必须在实时生产 Squid 服务器极其缓慢的压力下完成这一切,所以我确信这不是正确的方法。
但正确的做法是什么?
我在 Ubuntu 10.04 上运行 Squid 3,使用 SARG 进行报告。它大多运行良好,但我遇到了服务器因 SARG 报告而变得完全充满的问题。
我创建了这个脚本,它试图删除报告文件夹中超过 45 天的任何内容,但我认为它引起了一些问题,因为 SARG 从那时起就无法正常运行。
#!/bin/bash
find /var/www/squid-reports/* -type f -mtime +45 -exec rm -f {} \;
find /var/www/squid-reports/* -type d -mtime +45 -exec rmdir {} \;
Run Code Online (Sandbox Code Playgroud)
处理这个问题的推荐方法是什么?谢谢!