<div class="iteye-blog-content-contain" style="font-size: 14px;">
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">Squid工作原理</span></strong></div>
<div style="">Squid是Linux下一个缓存Internet数据的代理服务器软件,它接收用户的下载申请并自动处理所下载的数据。即当一个用户下载<a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.idcshare/"><span style="padding: 0px; margin: 0px; color: #0000ff;">www.idcshare</span></a>的页面,他请求squid为他取得这个页面,suqid会连接到申请<a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.idcshare/"><span style="padding: 0px; margin: 0px; color: #0000ff;">www.idcshare</span></a>的网站并请求该主页,接着把主页传给用户并自己保留一份.当下一次有其他用户请求同样页面时,squid会从磁盘中读到保存那份,这样数据就会迅速传输到用户的机器上.</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">Squid</strong><strong style="padding: 0px; margin: 0px;">支持以下协议</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px;">1) </span>客户端协议:HTTP .FTP.Gopher.WAIS.SSL</div>
<div style="">
<span style="padding: 0px; margin: 0px;">2) </span>缓存及管理协议:ICP(Internet Cache协议). HTCP(超文本缓冲协议).SNNP. Cache Digests</div>
<div style=""> </div>
<div style=""><strong style="padding: 0px; margin: 0px;">运行流程图:</strong></div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/152024656.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/152024656.jpg" alt="" width="650" border="0"></a></p>
<div style="">1) Client端向Server端发送一个资料需求封包;</div>
<div style="">2) Server端接收之后,先比对这个封包的『来源』与预计要前往的『目标』网站是否为可接受?如果来源与目标都是合法的,或者说,来源与目标网站我们的Proxy都能帮忙取得资料时,那么Server端会预计开始替Client取得资料。</div>
<div style="">3) Server首先会到自己的硬碟里面,也就是所谓的cache 查看一下有没有Client端所需要的资料,如果有的话,那就将资料直接送到Client端而不经过向Internet要求资料的程序;</div>
<div style="">4) 将数据传回给客户端使用</div>
<div style="">5)在经过1, 2, 3查寻知道cache没有资料,或者资料过期之后, Proxy会向Internet上面的目标网站要求资料;</div>
<div style="">6)在将资料取回之后, proxy会先将取得的资料『储存一份到cache当中』;</div>
<div style="">7)最后才将资料传回给Client端使用。</div>
<div style=""> </div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">代理服务器优点与类型</span></strong></div>
<div style=""><strong style="padding: 0px; margin: 0px;">优点:</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px;">1)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>通过缓存增加访问速度</div>
<div style="">
<span style="padding: 0px; margin: 0px;">2)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>提供用私有ip访问internet的方法</div>
<div style="">
<span style="padding: 0px; margin: 0px;">3)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>提高网络的安全性</div>
<div style="">
<span style="padding: 0px; margin: 0px;">4)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>方便对用户的管理</div>
<div style=""><strong style="padding: 0px; margin: 0px;">类型:</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px;">1) </span>标准代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151142997.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151142997.jpg" alt="" width="650" border="0"></a></p>
<div style="">
<span style="padding: 0px; margin: 0px;">2) </span>透明代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151310221.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151310221.jpg" alt="" width="650" border="0"></a></p>
<div style="">
<span style="padding: 0px; margin: 0px;">3) </span>反向代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151344541.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151344541.jpg" alt="" width="650" border="0"></a></p>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">安装前期准备工作</span></strong></div>
<div style="">
<strong style="padding: 0px; margin: 0px;">1</strong><strong style="padding: 0px; margin: 0px;">)源代码编译优化</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">一般情况下,优化参数都是通过</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">export</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">命令设定</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CFLAGS</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">和</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CXXFLAGS</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,然后</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">configure</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会自动读入,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">make</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会自动使用所选的优化参数。通过添加优化参数,让程序针对某个</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">型号和某个系统进行最大优化,减少文件大小、</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">使用率、内存使用率。优化后的程序,将不再具有跨系统跨平台的能力。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">首先查看</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">信息,然后根据</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">信息到</span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/Safe_Cflags"><span style="padding: 0px; margin: 0px; color: #0000ff;">http://gentoo-wiki.com/Safe_Cflags</span></a>去获取CPU优化参数</div>
<div style="">
<strong style="padding: 0px; margin: 0px;">技巧</strong><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">:直接是打不开</span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/Safe_Cflags"><span style="padding: 0px; margin: 0px; color: #0000ff;">http://gentoo-wiki.com/Safe_Cflags</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">http://www.proxyie.cn/</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">输入</span></a><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/"><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">http://gentoo-wiki.com</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,打开后点左侧栏的搜索,输入</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">cpu</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">。</span></a>,要fanqian,打开</div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">如下图:</span></div>
<div style=""> </div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151545770.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151545770.jpg" alt="" width="650" border="0"></a></span></div>
<div style=""># <strong style="padding: 0px; margin: 0px;">cat /proc/cpuinfo |more </strong> </div>
<div style="">processor<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">vendor_id<span style="padding: 0px; margin: 0px;"> : GenuineIntel</span>
</div>
<div style="">cpu family<span style="padding: 0px; margin: 0px;"> : 6</span>
</div>
<div style="">model<span style="padding: 0px; margin: 0px;"> : 23</span>
</div>
<div style="">model name<span style="padding: 0px; margin: 0px;"> : Intel(R) Xeon(R) CPU E5420 @ 2.50GHz</span>
</div>
<div style="">stepping<span style="padding: 0px; margin: 0px;"> : 10</span>
</div>
<div style="">cpu MHz<span style="padding: 0px; margin: 0px;"> : 2493.978</span>
</div>
<div style="">cache size<span style="padding: 0px; margin: 0px;"> : 6144 KB</span>
</div>
<div style="">physical id<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">siblings<span style="padding: 0px; margin: 0px;"> : 4</span>
</div>
<div style="">core id<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">cpu cores<span style="padding: 0px; margin: 0px;"> : 4</span>
</div>
<div style="">apicid<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">fdiv_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">hlt_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">f00f_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">coma_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">fpu<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">fpu_exception<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">cpuid level<span style="padding: 0px; margin: 0px;"> : 13</span>
</div>
<div style="">wp<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">flags<span style="padding: 0px; margin: 0px;"> : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush d</span>
</div>
<div style="">ts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr</div>
<div style="">lahf_lm</div>
<div style="">bogomips<span style="padding: 0px; margin: 0px;"> : 4987.95</span>
</div>
<div style=""> </div>
<div style="">由于服务器model name 是Intel(R) Xeon(R) CPU,我选择如下图:</div>
<div style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151431208.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151431208.jpg" alt="" width="650" border="0"></a></div>
<div style="">配置:</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CHOST="i686-pc-linux-gnu"</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CFLAGS="-march=Prescott -O2 -pipe -fomit-frame-pointer"</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CXXFLAGS="${CFLAGS}"</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">env</span>
</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151509288.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151509288.jpg" alt="" width="650" border="0"></a></p>
<div style=""><span style="padding: 0px; margin: 0px; color: red;">查看设置环境变量是否生效</span></div>
<div style="">红色标记,说明生效了.</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">3)</strong><strong style="padding: 0px; margin: 0px;">修改描述符参数值</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">文件描述符用来限制一个程序能同时打开的文件数目,默认是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">。也就是说,如果不修改文件描述符,那么一个程序只能同时打开</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">个文件,而</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">Squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">会同时打开成千上万个文件,所以远远是不够的,为了保证最高的效率和响应速度,要更改文件描述符的大小</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">.</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">两种情况:</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">a.</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用户每次访问</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">会按照需要打开文件,然后读取文件内容再返回给用户。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">b.squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">预先打开访问频率高的文件,用户访问</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">直接把内容返回给用户。相对来说,后面的方法可以对用户的请求进行更加快的反应。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">首先修改以下两个文件。</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">/usr/include/bits/typesizes.h<br style="padding: 0px; margin: 0px;">/usr/include/linux/posix_types.h</span><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">vi</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">打开上面的文件查找</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#define __FD_SETSIZE 1024</span><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">把</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">改为</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">65536</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,然后保存,这是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">Linux</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">能接受的最大数值。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">刚才编辑的这两个文件是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">C/C++</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">程序里面的头文件,编译</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会被自动引用。除了这两个文件以外,我们还需要对当前环境进行设置。也就是你用</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">ssh</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">登录到系统时的一些设定。每个登录进程都可以进行单独的设置,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">当关闭目前登录回话,环境变量的设置就失效了</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">.</span>
</div>
<div style="">
<strong style="padding: 0px; margin: 0px;">ulimit</strong><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用来设置当前环境的一些资源限制。这个命令是对环境进行设置,所以退出当前登录进程后命令将会失效。</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">我们输入下面的命令</span></div>
<pre><span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#ulimit -Hs 65536</span></pre>
<pre><span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#ulimit -n 65536</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">也可以永久修改这些限制,开机自动生效,配置如下:</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">vi /etc/security/limits.conf</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,添加以下内容</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">* soft nofile 65536 </span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">* hard nofile 65536</span></pre>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">H</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">参数是硬性限制,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">s</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">是堆栈上限,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">n</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">是文件描述符上限。</span>
</div>
<div style=""><strong style="padding: 0px; margin: 0px;">注释:</strong></div>
<div style="">ulimit 参数介绍:<br style="padding: 0px; margin: 0px;">-H 设置硬件资源限制.<br style="padding: 0px; margin: 0px;">-S 设置软件资源限制.<br style="padding: 0px; margin: 0px;">-a 显示当前所有的资源限制.<br style="padding: 0px; margin: 0px;">-c size:设置core文件的最大值.单位:blocks<br style="padding: 0px; margin: 0px;">-d size:设置数据段的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-f size:设置创建文件的最大值.单位:blocks<br style="padding: 0px; margin: 0px;">-l size:设置在内存中锁定进程的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-m size:设置可以使用的常驻内存的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-n size:设置内核可以同时打开的文件描述符的最大值.单位:n<br style="padding: 0px; margin: 0px;">-p size:设置管道缓冲区的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-s size:设置堆栈的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-t size:设置CPU使用时间的最大上限.单位:seconds<br style="padding: 0px; margin: 0px;">-v size:设置虚拟内存的最大值.单位:kbytes</div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">安装与配置</span></strong></div>
<div style=""><strong style="padding: 0px; margin: 0px;">安装</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">wget </span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE24.tar.gz"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE24.tar.gz</span></a>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> tar -zxvf squid-3.0.STABLE24.tar.gz</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">cd squid-3.0.STABLE24</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">./configure --prefix=/usr/local/squid\--enable-gnuregex\--enable-icmp\--enable-linux-netfilter\--enable-default-err-language="Simplify_Chinese"\--enable-kill-parent-hack\--enable-cache-digests\--enable-dlmalloc\--enable-poll\--enable-async-io=240\--enable-delay-pools\--with-filedescriptors=65536\--enable-snmp\--enable-arp-acl\--mandir=/usr/share/man/--with-large-files</span>
</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">注释</strong>:</div>
<div style="">可以用命令查看</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> ./configure --help</span>
</div>
<div style="">--enable-gnuregex</div>
<div style="">在访问控制列表和其他配置指令里,squid使用正则表达式作为匹配机制。GNU的正则表达式库包含在squid的源代码包里;它可以在没有内建正则表达式的操作系统中使用。./configure脚本侦察你系统中的正则表达式库,假如必要,它可以激活使用GNU正则表达式。如果因为某些理由,你想强制使用GNU正则表达式,比如在proxy未来的规划当中。可能利用到正则表示法的方式来抵挡一些恶意的网站,你可以将这个选项加到./configure命令后.</div>
<div style="">--enable-icmp</div>
<div style="">squid能利用ICMP消息来确定回环时间尺寸,非常象ping程序。你能使用该选项来激活这些功能。</div>
<div style="">--enable-linux-netfilter</div>
<div style="">Netfilter是linux 2.4系列内核的包过滤器名字。假如你想在linux2.4或以后的版本中使用HTTP拦截功能,那么激活该选项。</div>
<div style="">--enable-default-err-language=lang</div>
<div style="">该选项设置error_directory指令的默认值。例如,假如你想使用荷兰语,你能这样指定:</div>
<div style="">% ./configure --enable-default-err-language=Dutch</div>
<div style="">你也能在squid.conf里指定error_directory指令,在附录A中有描述。假如你忽略该选项,英语是默认错误语言。</div>
<div style="">--enable-kill-parent-hack</div>
<div style="">在我们关掉squid的时候,连同parent process 一起关掉</div>
<div style="">--enable-cache-digests</div>
<div style="">Cache消化是ICP的另一个替代,但有着截然不同的特性</div>
<div style="">--enable-dlmalloc[=LIB]</div>
<div style="">在一些系统上,内建的内存分配机制(malloc)在使用squid时表现不尽人意。使用--enable-dlmalloc选项将squid源代码包中的dlmalloc包编译和链接进来。假如你的系统中已安装dlmalloc,你能使用=LIB参数指定库的路径。</div>
<div style="">--enable-poll</div>
<div style="">unix提供两个相似的函数用以在I/O事件里扫描开放文件描述符:select()和poll()../configure脚本通常能非常好的计算出何时使用poll()来代替select().假如你想强制使用poll(),那么指定该选项。</div>
<div style=""> </div>
<div style="">--enable-async-io[=N_THREADS]</div>
<div style="">异步I/O是squid技术之一,用以提升存储性能。aufs模块使用大量的线程来执行磁盘I/O操作。该代码仅仅工作在linux和solaris系统中。=N_THREADS参数改变squid使用的线程数量。如果网站的服务器配置很高,可以尝试将这个数字改为160以上。如果是小网站的话,可以考虑降低到40左右.</div>
<div style="">请注意--enable-async-io是打开其他三个./configure选项的快捷方式,它等同于:</div>
<div style="">--with-aufs-threads=N_THREADS</div>
<div style="">--with-pthreads</div>
<div style="">--enable-storeio=ufs,aufs</div>
<div style=""> </div>
<div style="">--enable-delay-pools</div>
<div style="">延时池是squid用于传输形状或带宽限制的技术。该池由大量的客户端IP地址组成。当来自这些客户端的请求处于cache丢失状态,他们的响应可能被人工</div>
<div style=""> --with-filedescriptors=65536</div>
<div style="">支持最大文件描述符</div>
<div style="">--enable-snmp</div>
<div style="">简单网络管理协议(SNMP)是监视网络设备和服务器的流行方法。该选项导致编译过程去编译所有的SNMP相关的代码,包括一个裁切版本的CMU SNMP库。</div>
<div style="">--enable-arp-acl</div>
<div style="">允许基于MAC地址的存取过滤</div>
<div style="">--mandir=/usr/share/man</div>
<div style="">指定man的安装目录</div>
<div style="">--with-large-files</div>
<div style="">让log支持大于2G</div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">make; make install</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[3]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Entering directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Build Successful.</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Entering directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">make[2]: Nothing to be done for `install-exec-am'.</span><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: red;">==================</span></strong><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: red;">说明安装成功</span></strong>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Nothing to be done for `install-data-am'.</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"># </span></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">ll /usr/local/squid--enable-gnuregex/</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">总计</span><span style="padding: 0px; margin: 0px; color: black;"> 24</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 bin</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 etc</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 libexec</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 sbin</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 5 root root 4096 03-04 23:35 share</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 3 root root 4096 03-04 23:35 var</span></div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">bin/ :放置主要的squid执行scripts的目录,重要的是RunCache那个档案;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">etc/ :几乎所有的squid设定档都在这里;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">libexec/ :一些函式库;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">sbin/ :重要的就是那个squid的执行档!</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">share/ :一些错误讯息代码表示档案,以及一些小图示放置的目录;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">var/ :预设是放置log file的,不过我不喜欢放在这里,这点等一下我们会修改的!</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; color: red;">第一次运行</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">时,要先设置</span><span style="padding: 0px; margin: 0px; color: red;">/usr/local/squid/var</span><span style="padding: 0px; margin: 0px; color: red;">权限,还有在</span><span style="padding: 0px; margin: 0px; color: red;">/usr/local/squid/etc/squid.conf</span><span style="padding: 0px; margin: 0px; color: red;">添加主机,</span><span style="padding: 0px; margin: 0px; color: red;">visible_hostnam viong </span><span style="padding: 0px; margin: 0px; color: red;">并制定</span><span style="padding: 0px; margin: 0px; color: red;">http_port </span><span style="padding: 0px; margin: 0px; color: red;">端口号</span><span style="padding: 0px; margin: 0px; color: red;">.</span><span style="padding: 0px; margin: 0px; color: red;">这里预设个</span><span style="padding: 0px; margin: 0px; color: red;">80</span>
</div>
<div style=""> </div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"># chown -R nobody:nobody /usr/local/squid/var</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left"> </div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> /usr/local/squid/sbin/squid –zD</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red;">首次运行</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">需要初始化</span><span style="padding: 0px; margin: 0px; color: red;">cache</span><span style="padding: 0px; margin: 0px; color: red;">,由于</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">要验证其</span><span style="padding: 0px; margin: 0px; color: red;">DNS</span><span style="padding: 0px; margin: 0px; color: red;">可用才能启动,目前都没配置,所以我先禁用初始化</span><span style="padding: 0px; margin: 0px; color: red;">DNS</span><span style="padding: 0px; margin: 0px; color: red;">测试,先让</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">启动</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">Squid#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> netstat -ntpl |grep 80</span>
</div>
<div style="">tcp<span style="padding: 0px; margin: 0px;"> 0 0 0.0.0.0:80 0.0.0.0:* LISTEN </span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black;"> <span style="padding: 0px; margin: 0px; color: yellow;">/usr/local/squid/bin/squidclient -p 80 -h localhost mgr:info</span></span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">运行状态信息</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">HTTP/1.0 200 OK</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Server: squid/3.0.STABLE24</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Mime-Version: 1.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Date: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Content-Type: text/plain</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Expires: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Last-Modified: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">X-Cache: MISS from viong</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Via: 1.0 viong (squid/3.0.STABLE24)</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Proxy-Connection: close</span></div>
<div style=""> </div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Squid Object Cache: Version 3.0.STABLE24</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Start Time: Fri, 05 Mar 2010 14:42:48 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Current Time: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Connection information for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of clients accessing cache: 1</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTTP requests received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of ICP messages received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of ICP messages sent: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of queued ICP replies: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTCP messages received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTCP messages sent: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Request failure ratio: 0.00</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Average HTTP requests per minute since start: 0.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Average ICP messages per minute since start: 0.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Select loop called: 8659 times, 4.376 ms avg</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Cache information for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Hits as % of all requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Hits as % of bytes sent: 5min: -0.0%, 60min: -0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Disk hits as % of hit requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Swap size: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Swap capacity: 0.0% used, 100.0% free</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Mem size: 104 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Mem capacity: 1.3% used, 98.7% free</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Mean Object Size: 0.00 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Requests given to unlinkd: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Median Service Times (seconds) 5 min 60 min:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> HTTP Requests (All): 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Cache Misses: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Cache Hits: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Near Hits: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Not-Modified Replies: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> DNS Lookups: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> ICP Queries: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Resource usage for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> UP Time: 37.890 seconds</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Time: 0.070 seconds</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage: 0.18%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage, 5 minute avg: 0.00%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage, 60 minute avg: 0.00%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Process Data Segment Size via sbrk(): 2784 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Maximum Resident Size: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Page faults with physical i/o: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Memory usage for squid via mallinfo():</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total space in arena: 3052 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Ordinary blocks: 2938 KB 1 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Small blocks: 0 KB 0 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Holding blocks: 1520 KB 8 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Free Small blocks: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Free Ordinary blocks: 113 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total in use: 4458 KB 98%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total free: 113 KB 2%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total size: 4572 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Memory accounted for:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total accounted: 1886 KB 41%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPool accounted: 1886 KB 41%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPool unaccounted: 2685 KB 59%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPoolAlloc calls: 1504</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPoolFree calls: 481</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">File descriptor usage for squid:</span></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;"> Maximum number of file descriptors: <strong style="padding: 0px; margin: 0px;"> 65536</strong> </span><span style="padding: 0px; margin: 0px; color: red;"> =============</span><span style="padding: 0px; margin: 0px; color: red;">文件描述符</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Largest file desc currently in use: 16</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of file desc currently in use: 10</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Files queued for open: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Available number of file descriptors: 1014</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Reserved number of file descriptors: 100</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Store Disk files open: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Internal Data Structures:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 26 StoreEntries</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 26 StoreEntries with MemObjects</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 25 Hot Object Cache Items</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 0 on-disk objects</span></div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: black;">注释:</span></strong></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">Squidclient</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">参数:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">运行状态信息:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:info<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">内存使用情况:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:mem<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">已经缓存的列表:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:objects<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">的磁盘使用情况:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:diskd</span>
</div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red;">为了不每次输</span><span style="padding: 0px; margin: 0px; color: red;">ulimit -HSn 65536 ,squid</span><span style="padding: 0px; margin: 0px; color: red;">指定个启动脚本,复制一下脚本保存为</span><span style="padding: 0px; margin: 0px; color: red;">squid.sh</span>
</div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: #0070c0;">#!/bin/sh<br style="padding: 0px; margin: 0px;">#<br style="padding: 0px; margin: 0px;">ulimit -HSn 65536<br style="padding: 0px; margin: 0px;"># starts and stops Squid<br style="padding: 0px; margin: 0px;">case "$1" in<br style="padding: 0px; margin: 0px;">start)<br style="padding: 0px; margin: 0px;"> /usr/local/squid/sbin/squid -s<br style="padding: 0px; margin: 0px;"> echo -n ' Squid'<br style="padding: 0px; margin: 0px;"> ;;<br style="padding: 0px; margin: 0px;">stop)<br style="padding: 0px; margin: 0px;"> /usr/local/squid/sbin/squid -k shutdown<br style="padding: 0px; margin: 0px;"><br style="padding: 0px; margin: 0px;"> ;;<br style="padding: 0px; margin: 0px;">esac</span></strong></div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">以后启动或者停止</span><span style="padding: 0px; margin: 0px; color: black;">squid</span><span style="padding: 0px; margin: 0px; color: black;">,直接运行一下命令</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">sh squid.sh stop </span><span style="padding: 0px; margin: 0px; background-color: black; color: white;"> </span><span style="padding: 0px; margin: 0px;"> </span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> sh squid.sh start </span><span style="padding: 0px; margin: 0px; color: yellow;"> </span>
</div>
<div style=""><span style="padding: 0px; margin: 0px;"> </span></div>
</div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">Squid工作原理</span></strong></div>
<div style="">Squid是Linux下一个缓存Internet数据的代理服务器软件,它接收用户的下载申请并自动处理所下载的数据。即当一个用户下载<a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.idcshare/"><span style="padding: 0px; margin: 0px; color: #0000ff;">www.idcshare</span></a>的页面,他请求squid为他取得这个页面,suqid会连接到申请<a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.idcshare/"><span style="padding: 0px; margin: 0px; color: #0000ff;">www.idcshare</span></a>的网站并请求该主页,接着把主页传给用户并自己保留一份.当下一次有其他用户请求同样页面时,squid会从磁盘中读到保存那份,这样数据就会迅速传输到用户的机器上.</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">Squid</strong><strong style="padding: 0px; margin: 0px;">支持以下协议</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px;">1) </span>客户端协议:HTTP .FTP.Gopher.WAIS.SSL</div>
<div style="">
<span style="padding: 0px; margin: 0px;">2) </span>缓存及管理协议:ICP(Internet Cache协议). HTCP(超文本缓冲协议).SNNP. Cache Digests</div>
<div style=""> </div>
<div style=""><strong style="padding: 0px; margin: 0px;">运行流程图:</strong></div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/152024656.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/152024656.jpg" alt="" width="650" border="0"></a></p>
<div style="">1) Client端向Server端发送一个资料需求封包;</div>
<div style="">2) Server端接收之后,先比对这个封包的『来源』与预计要前往的『目标』网站是否为可接受?如果来源与目标都是合法的,或者说,来源与目标网站我们的Proxy都能帮忙取得资料时,那么Server端会预计开始替Client取得资料。</div>
<div style="">3) Server首先会到自己的硬碟里面,也就是所谓的cache 查看一下有没有Client端所需要的资料,如果有的话,那就将资料直接送到Client端而不经过向Internet要求资料的程序;</div>
<div style="">4) 将数据传回给客户端使用</div>
<div style="">5)在经过1, 2, 3查寻知道cache没有资料,或者资料过期之后, Proxy会向Internet上面的目标网站要求资料;</div>
<div style="">6)在将资料取回之后, proxy会先将取得的资料『储存一份到cache当中』;</div>
<div style="">7)最后才将资料传回给Client端使用。</div>
<div style=""> </div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">代理服务器优点与类型</span></strong></div>
<div style=""><strong style="padding: 0px; margin: 0px;">优点:</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px;">1)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>通过缓存增加访问速度</div>
<div style="">
<span style="padding: 0px; margin: 0px;">2)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>提供用私有ip访问internet的方法</div>
<div style="">
<span style="padding: 0px; margin: 0px;">3)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>提高网络的安全性</div>
<div style="">
<span style="padding: 0px; margin: 0px;">4)<span style="padding: 0px; margin: 0px; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"> </span></span>方便对用户的管理</div>
<div style=""><strong style="padding: 0px; margin: 0px;">类型:</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px;">1) </span>标准代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151142997.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151142997.jpg" alt="" width="650" border="0"></a></p>
<div style="">
<span style="padding: 0px; margin: 0px;">2) </span>透明代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151310221.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151310221.jpg" alt="" width="650" border="0"></a></p>
<div style="">
<span style="padding: 0px; margin: 0px;">3) </span>反向代理服务器</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151344541.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151344541.jpg" alt="" width="650" border="0"></a></p>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">安装前期准备工作</span></strong></div>
<div style="">
<strong style="padding: 0px; margin: 0px;">1</strong><strong style="padding: 0px; margin: 0px;">)源代码编译优化</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">一般情况下,优化参数都是通过</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">export</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">命令设定</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CFLAGS</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">和</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CXXFLAGS</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,然后</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">configure</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会自动读入,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">make</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会自动使用所选的优化参数。通过添加优化参数,让程序针对某个</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">型号和某个系统进行最大优化,减少文件大小、</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">使用率、内存使用率。优化后的程序,将不再具有跨系统跨平台的能力。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">首先查看</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">信息,然后根据</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">CPU</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">信息到</span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/Safe_Cflags"><span style="padding: 0px; margin: 0px; color: #0000ff;">http://gentoo-wiki.com/Safe_Cflags</span></a>去获取CPU优化参数</div>
<div style="">
<strong style="padding: 0px; margin: 0px;">技巧</strong><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">:直接是打不开</span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/Safe_Cflags"><span style="padding: 0px; margin: 0px; color: #0000ff;">http://gentoo-wiki.com/Safe_Cflags</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">http://www.proxyie.cn/</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">输入</span></a><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://gentoo-wiki.com/"><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">http://gentoo-wiki.com</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,打开后点左侧栏的搜索,输入</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">cpu</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">。</span></a>,要fanqian,打开</div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">如下图:</span></div>
<div style=""> </div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151545770.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151545770.jpg" alt="" width="650" border="0"></a></span></div>
<div style=""># <strong style="padding: 0px; margin: 0px;">cat /proc/cpuinfo |more </strong> </div>
<div style="">processor<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">vendor_id<span style="padding: 0px; margin: 0px;"> : GenuineIntel</span>
</div>
<div style="">cpu family<span style="padding: 0px; margin: 0px;"> : 6</span>
</div>
<div style="">model<span style="padding: 0px; margin: 0px;"> : 23</span>
</div>
<div style="">model name<span style="padding: 0px; margin: 0px;"> : Intel(R) Xeon(R) CPU E5420 @ 2.50GHz</span>
</div>
<div style="">stepping<span style="padding: 0px; margin: 0px;"> : 10</span>
</div>
<div style="">cpu MHz<span style="padding: 0px; margin: 0px;"> : 2493.978</span>
</div>
<div style="">cache size<span style="padding: 0px; margin: 0px;"> : 6144 KB</span>
</div>
<div style="">physical id<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">siblings<span style="padding: 0px; margin: 0px;"> : 4</span>
</div>
<div style="">core id<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">cpu cores<span style="padding: 0px; margin: 0px;"> : 4</span>
</div>
<div style="">apicid<span style="padding: 0px; margin: 0px;"> : 0</span>
</div>
<div style="">fdiv_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">hlt_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">f00f_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">coma_bug<span style="padding: 0px; margin: 0px;"> : no</span>
</div>
<div style="">fpu<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">fpu_exception<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">cpuid level<span style="padding: 0px; margin: 0px;"> : 13</span>
</div>
<div style="">wp<span style="padding: 0px; margin: 0px;"> : yes</span>
</div>
<div style="">flags<span style="padding: 0px; margin: 0px;"> : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush d</span>
</div>
<div style="">ts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr</div>
<div style="">lahf_lm</div>
<div style="">bogomips<span style="padding: 0px; margin: 0px;"> : 4987.95</span>
</div>
<div style=""> </div>
<div style="">由于服务器model name 是Intel(R) Xeon(R) CPU,我选择如下图:</div>
<div style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151431208.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151431208.jpg" alt="" width="650" border="0"></a></div>
<div style="">配置:</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CHOST="i686-pc-linux-gnu"</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CFLAGS="-march=Prescott -O2 -pipe -fomit-frame-pointer"</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">export CXXFLAGS="${CFLAGS}"</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">env</span>
</div>
<p style=""><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://img1.51cto.com/attachment/201003/151509288.jpg" target="_blank"><img style="padding: 0px; margin: 0px; vertical-align: top; border-style: none;" src="http://img1.51cto.com/attachment/201003/151509288.jpg" alt="" width="650" border="0"></a></p>
<div style=""><span style="padding: 0px; margin: 0px; color: red;">查看设置环境变量是否生效</span></div>
<div style="">红色标记,说明生效了.</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">3)</strong><strong style="padding: 0px; margin: 0px;">修改描述符参数值</strong>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">文件描述符用来限制一个程序能同时打开的文件数目,默认是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">。也就是说,如果不修改文件描述符,那么一个程序只能同时打开</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">个文件,而</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">Squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">会同时打开成千上万个文件,所以远远是不够的,为了保证最高的效率和响应速度,要更改文件描述符的大小</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">.</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">两种情况:</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">a.</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用户每次访问</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">会按照需要打开文件,然后读取文件内容再返回给用户。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">b.squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">预先打开访问频率高的文件,用户访问</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">直接把内容返回给用户。相对来说,后面的方法可以对用户的请求进行更加快的反应。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">首先修改以下两个文件。</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">/usr/include/bits/typesizes.h<br style="padding: 0px; margin: 0px;">/usr/include/linux/posix_types.h</span><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">vi</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">打开上面的文件查找</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#define __FD_SETSIZE 1024</span><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">把</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">1024</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">改为</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">65536</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,然后保存,这是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">Linux</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">能接受的最大数值。</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;"><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">刚才编辑的这两个文件是</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">C/C++</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">程序里面的头文件,编译</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">squid</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">的时候会被自动引用。除了这两个文件以外,我们还需要对当前环境进行设置。也就是你用</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">ssh</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">登录到系统时的一些设定。每个登录进程都可以进行单独的设置,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">当关闭目前登录回话,环境变量的设置就失效了</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">.</span>
</div>
<div style="">
<strong style="padding: 0px; margin: 0px;">ulimit</strong><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">用来设置当前环境的一些资源限制。这个命令是对环境进行设置,所以退出当前登录进程后命令将会失效。</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">我们输入下面的命令</span></div>
<pre><span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#ulimit -Hs 65536</span></pre>
<pre><span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">#ulimit -n 65536</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">也可以永久修改这些限制,开机自动生效,配置如下:</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">vi /etc/security/limits.conf</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">,添加以下内容</span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">* soft nofile 65536 </span></pre>
<pre><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">* hard nofile 65536</span></pre>
<div style="">
<span style="padding: 0px; margin: 0px; font-size: 10.5pt;">H</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">参数是硬性限制,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">s</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">是堆栈上限,</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">n</span><span style="padding: 0px; margin: 0px; font-size: 10.5pt;">是文件描述符上限。</span>
</div>
<div style=""><strong style="padding: 0px; margin: 0px;">注释:</strong></div>
<div style="">ulimit 参数介绍:<br style="padding: 0px; margin: 0px;">-H 设置硬件资源限制.<br style="padding: 0px; margin: 0px;">-S 设置软件资源限制.<br style="padding: 0px; margin: 0px;">-a 显示当前所有的资源限制.<br style="padding: 0px; margin: 0px;">-c size:设置core文件的最大值.单位:blocks<br style="padding: 0px; margin: 0px;">-d size:设置数据段的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-f size:设置创建文件的最大值.单位:blocks<br style="padding: 0px; margin: 0px;">-l size:设置在内存中锁定进程的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-m size:设置可以使用的常驻内存的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-n size:设置内核可以同时打开的文件描述符的最大值.单位:n<br style="padding: 0px; margin: 0px;">-p size:设置管道缓冲区的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-s size:设置堆栈的最大值.单位:kbytes<br style="padding: 0px; margin: 0px;">-t size:设置CPU使用时间的最大上限.单位:seconds<br style="padding: 0px; margin: 0px;">-v size:设置虚拟内存的最大值.单位:kbytes</div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; font-size: x-large;">安装与配置</span></strong></div>
<div style=""><strong style="padding: 0px; margin: 0px;">安装</strong></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">wget </span><a style="padding: 0px; margin: 0px; color: #2c628d;" href="http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE24.tar.gz"><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE24.tar.gz</span></a>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> tar -zxvf squid-3.0.STABLE24.tar.gz</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">cd squid-3.0.STABLE24</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">./configure --prefix=/usr/local/squid\--enable-gnuregex\--enable-icmp\--enable-linux-netfilter\--enable-default-err-language="Simplify_Chinese"\--enable-kill-parent-hack\--enable-cache-digests\--enable-dlmalloc\--enable-poll\--enable-async-io=240\--enable-delay-pools\--with-filedescriptors=65536\--enable-snmp\--enable-arp-acl\--mandir=/usr/share/man/--with-large-files</span>
</div>
<div style=""> </div>
<div style="">
<strong style="padding: 0px; margin: 0px;">注释</strong>:</div>
<div style="">可以用命令查看</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> ./configure --help</span>
</div>
<div style="">--enable-gnuregex</div>
<div style="">在访问控制列表和其他配置指令里,squid使用正则表达式作为匹配机制。GNU的正则表达式库包含在squid的源代码包里;它可以在没有内建正则表达式的操作系统中使用。./configure脚本侦察你系统中的正则表达式库,假如必要,它可以激活使用GNU正则表达式。如果因为某些理由,你想强制使用GNU正则表达式,比如在proxy未来的规划当中。可能利用到正则表示法的方式来抵挡一些恶意的网站,你可以将这个选项加到./configure命令后.</div>
<div style="">--enable-icmp</div>
<div style="">squid能利用ICMP消息来确定回环时间尺寸,非常象ping程序。你能使用该选项来激活这些功能。</div>
<div style="">--enable-linux-netfilter</div>
<div style="">Netfilter是linux 2.4系列内核的包过滤器名字。假如你想在linux2.4或以后的版本中使用HTTP拦截功能,那么激活该选项。</div>
<div style="">--enable-default-err-language=lang</div>
<div style="">该选项设置error_directory指令的默认值。例如,假如你想使用荷兰语,你能这样指定:</div>
<div style="">% ./configure --enable-default-err-language=Dutch</div>
<div style="">你也能在squid.conf里指定error_directory指令,在附录A中有描述。假如你忽略该选项,英语是默认错误语言。</div>
<div style="">--enable-kill-parent-hack</div>
<div style="">在我们关掉squid的时候,连同parent process 一起关掉</div>
<div style="">--enable-cache-digests</div>
<div style="">Cache消化是ICP的另一个替代,但有着截然不同的特性</div>
<div style="">--enable-dlmalloc[=LIB]</div>
<div style="">在一些系统上,内建的内存分配机制(malloc)在使用squid时表现不尽人意。使用--enable-dlmalloc选项将squid源代码包中的dlmalloc包编译和链接进来。假如你的系统中已安装dlmalloc,你能使用=LIB参数指定库的路径。</div>
<div style="">--enable-poll</div>
<div style="">unix提供两个相似的函数用以在I/O事件里扫描开放文件描述符:select()和poll()../configure脚本通常能非常好的计算出何时使用poll()来代替select().假如你想强制使用poll(),那么指定该选项。</div>
<div style=""> </div>
<div style="">--enable-async-io[=N_THREADS]</div>
<div style="">异步I/O是squid技术之一,用以提升存储性能。aufs模块使用大量的线程来执行磁盘I/O操作。该代码仅仅工作在linux和solaris系统中。=N_THREADS参数改变squid使用的线程数量。如果网站的服务器配置很高,可以尝试将这个数字改为160以上。如果是小网站的话,可以考虑降低到40左右.</div>
<div style="">请注意--enable-async-io是打开其他三个./configure选项的快捷方式,它等同于:</div>
<div style="">--with-aufs-threads=N_THREADS</div>
<div style="">--with-pthreads</div>
<div style="">--enable-storeio=ufs,aufs</div>
<div style=""> </div>
<div style="">--enable-delay-pools</div>
<div style="">延时池是squid用于传输形状或带宽限制的技术。该池由大量的客户端IP地址组成。当来自这些客户端的请求处于cache丢失状态,他们的响应可能被人工</div>
<div style=""> --with-filedescriptors=65536</div>
<div style="">支持最大文件描述符</div>
<div style="">--enable-snmp</div>
<div style="">简单网络管理协议(SNMP)是监视网络设备和服务器的流行方法。该选项导致编译过程去编译所有的SNMP相关的代码,包括一个裁切版本的CMU SNMP库。</div>
<div style="">--enable-arp-acl</div>
<div style="">允许基于MAC地址的存取过滤</div>
<div style="">--mandir=/usr/share/man</div>
<div style="">指定man的安装目录</div>
<div style="">--with-large-files</div>
<div style="">让log支持大于2G</div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">make; make install</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[3]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24/tools'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Entering directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Build Successful.</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Entering directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">make[2]: Nothing to be done for `install-exec-am'.</span><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: red;">==================</span></strong><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: red;">说明安装成功</span></strong>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Nothing to be done for `install-data-am'.</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[2]: Leaving directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">make[1]: Leaving directory `/root/soft/squid-3.0.STABLE24'</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"># </span></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">ll /usr/local/squid--enable-gnuregex/</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">总计</span><span style="padding: 0px; margin: 0px; color: black;"> 24</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 bin</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 etc</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 libexec</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 2 root root 4096 03-04 23:35 sbin</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 5 root root 4096 03-04 23:35 share</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">drwxr-xr-x 3 root root 4096 03-04 23:35 var</span></div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">bin/ :放置主要的squid执行scripts的目录,重要的是RunCache那个档案;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">etc/ :几乎所有的squid设定档都在这里;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">libexec/ :一些函式库;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">sbin/ :重要的就是那个squid的执行档!</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">share/ :一些错误讯息代码表示档案,以及一些小图示放置的目录;</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">var/ :预设是放置log file的,不过我不喜欢放在这里,这点等一下我们会修改的!</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; color: red;">第一次运行</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">时,要先设置</span><span style="padding: 0px; margin: 0px; color: red;">/usr/local/squid/var</span><span style="padding: 0px; margin: 0px; color: red;">权限,还有在</span><span style="padding: 0px; margin: 0px; color: red;">/usr/local/squid/etc/squid.conf</span><span style="padding: 0px; margin: 0px; color: red;">添加主机,</span><span style="padding: 0px; margin: 0px; color: red;">visible_hostnam viong </span><span style="padding: 0px; margin: 0px; color: red;">并制定</span><span style="padding: 0px; margin: 0px; color: red;">http_port </span><span style="padding: 0px; margin: 0px; color: red;">端口号</span><span style="padding: 0px; margin: 0px; color: red;">.</span><span style="padding: 0px; margin: 0px; color: red;">这里预设个</span><span style="padding: 0px; margin: 0px; color: red;">80</span>
</div>
<div style=""> </div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"></span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"># chown -R nobody:nobody /usr/local/squid/var</span>
</div>
<div style="padding: 0px; margin: 0px; color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px;" align="left"> </div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> /usr/local/squid/sbin/squid –zD</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red;">首次运行</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">需要初始化</span><span style="padding: 0px; margin: 0px; color: red;">cache</span><span style="padding: 0px; margin: 0px; color: red;">,由于</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">要验证其</span><span style="padding: 0px; margin: 0px; color: red;">DNS</span><span style="padding: 0px; margin: 0px; color: red;">可用才能启动,目前都没配置,所以我先禁用初始化</span><span style="padding: 0px; margin: 0px; color: red;">DNS</span><span style="padding: 0px; margin: 0px; color: red;">测试,先让</span><span style="padding: 0px; margin: 0px; color: red;">squid</span><span style="padding: 0px; margin: 0px; color: red;">启动</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">Squid#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> netstat -ntpl |grep 80</span>
</div>
<div style="">tcp<span style="padding: 0px; margin: 0px;"> 0 0 0.0.0.0:80 0.0.0.0:* LISTEN </span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black;"> <span style="padding: 0px; margin: 0px; color: yellow;">/usr/local/squid/bin/squidclient -p 80 -h localhost mgr:info</span></span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: red; font-size: 10pt;">运行状态信息</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">HTTP/1.0 200 OK</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Server: squid/3.0.STABLE24</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Mime-Version: 1.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Date: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Content-Type: text/plain</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Expires: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Last-Modified: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">X-Cache: MISS from viong</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Via: 1.0 viong (squid/3.0.STABLE24)</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Proxy-Connection: close</span></div>
<div style=""> </div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Squid Object Cache: Version 3.0.STABLE24</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Start Time: Fri, 05 Mar 2010 14:42:48 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Current Time: Fri, 05 Mar 2010 14:43:26 GMT</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Connection information for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of clients accessing cache: 1</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTTP requests received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of ICP messages received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of ICP messages sent: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of queued ICP replies: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTCP messages received: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of HTCP messages sent: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Request failure ratio: 0.00</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Average HTTP requests per minute since start: 0.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Average ICP messages per minute since start: 0.0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Select loop called: 8659 times, 4.376 ms avg</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Cache information for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Hits as % of all requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Hits as % of bytes sent: 5min: -0.0%, 60min: -0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Disk hits as % of hit requests: 5min: 0.0%, 60min: 0.0%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Swap size: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Swap capacity: 0.0% used, 100.0% free</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Mem size: 104 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Storage Mem capacity: 1.3% used, 98.7% free</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Mean Object Size: 0.00 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Requests given to unlinkd: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Median Service Times (seconds) 5 min 60 min:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> HTTP Requests (All): 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Cache Misses: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Cache Hits: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Near Hits: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Not-Modified Replies: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> DNS Lookups: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> ICP Queries: 0.00000 0.00000</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Resource usage for squid:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> UP Time: 37.890 seconds</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Time: 0.070 seconds</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage: 0.18%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage, 5 minute avg: 0.00%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> CPU Usage, 60 minute avg: 0.00%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Process Data Segment Size via sbrk(): 2784 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Maximum Resident Size: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Page faults with physical i/o: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Memory usage for squid via mallinfo():</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total space in arena: 3052 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Ordinary blocks: 2938 KB 1 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Small blocks: 0 KB 0 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Holding blocks: 1520 KB 8 blks</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Free Small blocks: 0 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Free Ordinary blocks: 113 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total in use: 4458 KB 98%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total free: 113 KB 2%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total size: 4572 KB</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Memory accounted for:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Total accounted: 1886 KB 41%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPool accounted: 1886 KB 41%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPool unaccounted: 2685 KB 59%</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPoolAlloc calls: 1504</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> memPoolFree calls: 481</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">File descriptor usage for squid:</span></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;"> Maximum number of file descriptors: <strong style="padding: 0px; margin: 0px;"> 65536</strong> </span><span style="padding: 0px; margin: 0px; color: red;"> =============</span><span style="padding: 0px; margin: 0px; color: red;">文件描述符</span>
</div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Largest file desc currently in use: 16</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Number of file desc currently in use: 10</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Files queued for open: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Available number of file descriptors: 1014</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Reserved number of file descriptors: 100</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> Store Disk files open: 0</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;">Internal Data Structures:</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 26 StoreEntries</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 26 StoreEntries with MemObjects</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 25 Hot Object Cache Items</span></div>
<div style=""><span style="padding: 0px; margin: 0px; color: black;"> 0 on-disk objects</span></div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: black;">注释:</span></strong></div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">Squidclient</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">参数:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"><br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">运行状态信息:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:info<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">内存使用情况:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:mem<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">已经缓存的列表:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:objects<br style="padding: 0px; margin: 0px;"></span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">取得</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">squid</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;">的磁盘使用情况:</span><span style="padding: 0px; margin: 0px; color: black; font-size: 10pt;"> squidclient -p 80 mgr:diskd</span>
</div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; color: red;">为了不每次输</span><span style="padding: 0px; margin: 0px; color: red;">ulimit -HSn 65536 ,squid</span><span style="padding: 0px; margin: 0px; color: red;">指定个启动脚本,复制一下脚本保存为</span><span style="padding: 0px; margin: 0px; color: red;">squid.sh</span>
</div>
<div style=""><strong style="padding: 0px; margin: 0px;"><span style="padding: 0px; margin: 0px; color: #0070c0;">#!/bin/sh<br style="padding: 0px; margin: 0px;">#<br style="padding: 0px; margin: 0px;">ulimit -HSn 65536<br style="padding: 0px; margin: 0px;"># starts and stops Squid<br style="padding: 0px; margin: 0px;">case "$1" in<br style="padding: 0px; margin: 0px;">start)<br style="padding: 0px; margin: 0px;"> /usr/local/squid/sbin/squid -s<br style="padding: 0px; margin: 0px;"> echo -n ' Squid'<br style="padding: 0px; margin: 0px;"> ;;<br style="padding: 0px; margin: 0px;">stop)<br style="padding: 0px; margin: 0px;"> /usr/local/squid/sbin/squid -k shutdown<br style="padding: 0px; margin: 0px;"><br style="padding: 0px; margin: 0px;"> ;;<br style="padding: 0px; margin: 0px;">esac</span></strong></div>
<div style=""> </div>
<div style="">
<span style="padding: 0px; margin: 0px; color: black;">以后启动或者停止</span><span style="padding: 0px; margin: 0px; color: black;">squid</span><span style="padding: 0px; margin: 0px; color: black;">,直接运行一下命令</span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;"># </span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;">sh squid.sh stop </span><span style="padding: 0px; margin: 0px; background-color: black; color: white;"> </span><span style="padding: 0px; margin: 0px;"> </span>
</div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">#</span><span style="padding: 0px; margin: 0px; background-color: black; color: yellow;"> sh squid.sh start </span><span style="padding: 0px; margin: 0px; color: yellow;"> </span>
</div>
<div style=""><span style="padding: 0px; margin: 0px;"> </span></div>
</div>