`
lusterfly
  • 浏览: 99059 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

squid代理服务器浏览网页速度慢优化

阅读更多

起由:Your cache is running out of filedescriptors

41的squid代理服务器出现以上警告,导致浏览网页速度超慢。

优化步骤:

1.查看

# ulimit -n
1024

需要增大文件描述符,需要调整Ubuntu内核参数,调整方法如下:

2.squid重运行configure,重新编译安装

3.安装参数如下(./configure的配置项

4.重新启动squid后,检查参数配置是否生效。squidclient mgr:info

**************************************************

在文件/etc/security/limits.conf

中添加user hard nofile 65533

在/etc/pam.d/common-session
添加: session required pam_limits.so

Some versions of squid have a compile-time limitation of 1024 maximum that cannot be increased by using ulimit at run-time.

 

A new configuruation option max_filedesc has been added to the following versions of Squid:

 

Red Hat Enterprise Linux 3: squid-2.5.STABLE3-6.3E.18

Red Hat Enterprise Linux 4: squid-2.5.STABLE14-1.4E

(This option is included in Squid for Red Hat Enterprise Linux 5 by default.)

 

Squid needs to be updated to the specified versions or above in order to use the new configuration option.

 

For example, to increase the maximum file descriptors to 4096, please do the following:

 

  1. In /etc/security/limits.conf , add this line:

    
     * - nofile 4096
     

     

  2. Save the file, logout and re-login to a shell. Use "ulimit" to check:

    
     # ulimit -a
     open files (-n) 4096
     

     

  3. Modify the /etc/squid/squid.conf and add this line:

    
     max_filedesc 4096
     

    (Notice: the value of max_filedesc should be the same as the value of nofile in /etc/security/limits.conf)

  4. Restart the squid service:

    
     # service squid restart
     

     

Use "squidclient" to check:

 


 # squidclient mgr:info

File descriptor usage for squid:
 Maximum number of file descriptors: 4096
*****************************************************

 

./configure的配置项

./configure --prefix=/usr/local/squid --with-large-files --enable-useragent-log --enable-referer-log --enable-linux-netfilter --enable-x-accelerator-vary --disable-internal-dns --disable-mempools --with-maxfd=65535

3.0版本去掉了以下选项:

--enable-dlmalloc 不再需要

--enable-epoll 系统会自己选择最优的I/O Loop Method

--enable-truncate 不再需要

--enable-follow-x-forwarded-for 没有此项配置了

增加了以下选项:

--disable-mempools 相当于2.7配置文件里面的memory_pools off,适合内存使用较大的情况,系统会调用free()来清除没用到的缓存内存

--with-maxfd=65535 相当于ulimit -n 65535,2.7配置文件里面的max_filedescriptors 65535

 

******************************************************************************

3.8 重运行configure

有时候你可能发现有必要重新运行./configure。例如,假如你调整了内核参数,你必须再次运行./configure以使它能发现新设置。当你阅读本书时,你也发现你必须使用./configure选项来激活所需的功能。

以相同的选项重运行./configure,使用如下命令:

%config.status --recheck

另一个技术是`touch config.status`文件,它更新了该文件的时间戳。这导致make在编译源代码之前,重新运行./configure脚本:

% touch config.status
      
% make
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics