squid!Your cache is running out of file

lfree發表於2014-02-21

[20140221]squid WARNING! Your cache is running out of filedescriptors.txt

--這一陣子,我們的代理出現一些問題.
--我檢查發現如下:
2014/02/21 14:53:10| client_side.cc(2993) okToAccept: WARNING! Your cache is running out of filedescriptors

--看來檔案描述設定太小,前面的管理人員設定有問題.我google,找到一些連結:

# squidclient -p 31888  mgr:info | grep 'file descri'
        Maximum number of file descriptors:   1024
        Available number of file descriptors:   12
        Reserved number of file descriptors:   100

--注意這樣寫不行.squidclient mgr:info -p 31888  ,Available number of file descriptors已經很小.

--增加file descriptors的方法,修改/etc/security/limits.conf:

Squid increase the maximum file descriptors

First, update /etc/security/limits.conf file:
# vi /etc/security/limits.conf
Append following line to increase current limit from 1024 to 4096:
* - nofile 4096
Save and close the file. You must re-login to check new limits:
# ulimit -a | grep 'open files'
Sample output:

open files                      (-n) 4096


Next you need to set the maximum number of open file descriptors by modifying squid proxy server configuration as per
your Linux distribution.

Set max_filedesc under RHEL / Red Hat / CentOS / Fedora Linux

Stop the Squid as changes of this value isn't respected by reconfigure command. This value should be changed only if
there isn't any active squid process.

# service squid stop
Open /etc/squid/squid.conf file
# vi /etc/squid/squid.conf
Append / add / modify max_filedesc directive:
max_filedesc 4096
Save and close the file. Start the squid proxy server:
# service squid start
Now again run squidclient command or check log files for messages:
# squidclient mgr:info
Set max_filedesc under Ubuntu / Debian Linux

First, stop squid proxy server, enter:
# /etc/init.d/squid stop
OR
$ sudo /etc/init.d/squid stop

Open /etc/default/squid to set max. number of filedescriptors to use. You can increase this on a busy
cache to a maximum of (currently) 4096 filedescriptors. Default is 1024.

$ sudo vi /etc/default/squid
OR
# vi /etc/default/squid
Now set SQUID_MAXFD:
SQUID_MAXFD=4096
Save and close the file. Start the squid proxy server:
$ sudo /etc/init.d/squid start
Verify that it is working with new limits:
# squidclient mgr:info | grep 'file descri'

--我選擇第1種方式修改.增加到65536.要重啟squid就可以了.

# squidclient -p 31888  mgr:info | grep -A7 'File descriptor usage for squid'
File descriptor usage for squid:
        Maximum number of file descriptors:   65536
        Largest file desc currently in use:   2388
        Number of file desc currently in use: 2248
        Files queued for open:                   0
        Available number of file descriptors: 63288
        Reserved number of file descriptors:   100
        Store Disk files open:                   4

--可以發現現Number of file desc currently in use增加到2248.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1085012/,如需轉載,請註明出處,否則將追究法律責任。

相關文章