在Ubuntu上使用squid文件描述符

我在Ubuntu 10.04 64位上运行Squid 2.7。 我遇到了Squid耗尽文件描述符的问题,在/var/log/squid/cache.log中显示以下错误:

警告! 您的caching正在耗尽文件描述符

我检查了:

squidclient mgr:info | grep'文件描述'

它表明我只有1024个文件描述符可用。

我更改了/etc/security/limits.conf,最后添加了这个:

* soft nofile 32768 * hard nofile 32768 proxy soft nofile 32768 proxy hard nofile 32768 

添加到/etc/squid/squid.conf:

 max_filedescriptors 32768 

还改了/ etc / default / squid:

 SQUID_MAXFD=32768 

没有什么工作。 最后我编辑了/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 ...> 

这工作! 🙂

我必须在现场生产的Squid服务器的压力下做到这一切,这是非常缓慢的,所以我相信这不是正确的做法。

但是,正确的做法是什么?

您必须在squid init脚本中添加ulimit行,并在squid.conf中增加max_filedescriptors。 这是两个关键的步骤。 你不再需要从源码编译鱿鱼来增加这个限制。 这是你真正的老鱿鱼版本。

我以前也有同样的问题。 我无法增加quid文件描述符的数量。

除了你所做的,我使用下面的configuration选项来configurationsquid:

 ./configure --prefix=/usr/local/squid --enable-start-stop-daemon --with-filedescriptors=65536 --enable-storeio=ufs,aufs --with-aufs-threads=10 

案件的重要部分是:

 --with-filedescriptors=65536 

做完这个并重新启动鱿鱼,我得到了最大值的文件描述符:65536。

当然,这需要从源而不是从命令安装鱿鱼:

 apt-get install squid 

/etc/init.d/squid是/ lib / init / upstart-job的一个符号链接,所以你最初的build议提出了所有新兴服务的限制。

我同意原来的问题/解决scheme引起了文件描述符限制,所以谢谢你。 理想情况下,不提高文件描述符的解决scheme会更好。