- 浏览: 66987 次
- 性别:
- 来自: 福建
文章分类
最新评论
<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="">[root@server soft]# <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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]</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;">[root@server soft]</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;">[root@server soft]# </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;">[root@server soft]#</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;">[root@server soft]# </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;">[root@serversquid-3.0.STABLE24]#</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;">[root@viong squid-3.0.STABLE24]#</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;">[root@server squid-3.0.STABLE24]# </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;">[root@server squid-3.0.STABLE24]# </span></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">[root@server squid-3.0.STABLE24]# </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;">[root@server squid-3.0.STABLE24]</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;">[root@server squid-3.0.STABLE24]#</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[root@viong soft]#</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;">[root@server squid-3.0.STABLE24]#</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;">[root@viong soft]# </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;">[root@viong soft]#</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="">[root@server soft]# <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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]#</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;">[root@server soft]</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;">[root@server soft]</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;">[root@server soft]# </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;">[root@server soft]#</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;">[root@server soft]# </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;">[root@serversquid-3.0.STABLE24]#</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;">[root@viong squid-3.0.STABLE24]#</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;">[root@server squid-3.0.STABLE24]# </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;">[root@server squid-3.0.STABLE24]# </span></div>
<div style="">
<span style="padding: 0px; margin: 0px; background-color: black; color: white;">[root@server squid-3.0.STABLE24]# </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;">[root@server squid-3.0.STABLE24]</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;">[root@server squid-3.0.STABLE24]#</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[root@viong soft]#</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;">[root@server squid-3.0.STABLE24]#</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;">[root@viong soft]# </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;">[root@viong soft]#</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>
发表评论
-
Linux下查看apache连接数
2019-03-08 14:38 3811、查看apache当前并发访问数: #对比 ... -
centos定时全量备份mysql
2018-08-31 16:05 384#!/bin/bash db_user="r ... -
centos下升级php5.3到php5.6
2017-12-19 08:40 456Talk is cheap, show me the c ... -
linux 的 cp复制命令
2016-07-21 08:22 6851、使用cp命令的-n参数即可跳过相同的文件 。2、cp命令使 ... -
RSync实现文件备份同步
2016-05-24 11:51 374转自:http://www.mike.org.cn/blo ... -
在Ubuntu下安装GCC和其他一些Linux系统有点不一样
2015-06-19 13:59 641在Ubuntu下安装GCC和其他一些Linux系统有点不一样 ... -
mysql 数据目录变动
2015-06-05 17:16 499sudo service mysql stop sudo ... -
ubuntu下如何更改mysql数据存放路径
2015-06-04 08:41 555ubuntu下如何更改mysql数据存放路径 很多 ... -
Ubuntu安装之,硬盘分区
2015-06-02 14:08 1098关于分区 引子:http://blog.csdn.net/ ... -
Ubuntu NFS服务器的配置
2015-06-02 11:27 444sudo mount /dev/sda6 /momo ... -
Ubuntu cron 定时执行任务
2015-05-19 13:48 549sudo crontab -u root -e * ... -
详谈CentOS系统中安装PHP的方法
2015-05-07 10:25 311CentOS系统中安装php的 ... -
CentOS上如何把Web服务器从Apache换到Nginx
2015-03-20 09:15 742CentOS上如何把Web服务器从Apache换到Nginx ... -
使用WinSCP软件在windows和Linux中进行文件传输
2015-03-18 08:54 735当我们的开发机是Window ... -
Redis快速入门:安装、配置和操作
2015-03-08 11:50 458[size=x-large][size=medium]Redi ... -
Ubuntu apt-get方法安装phpmyadmin(转)
2015-03-03 10:50 511Ubuntu apt-get方法安装phpm ... -
vi使用
2015-03-03 10:50 3301、vi的基本概念 基本上vi可以分为 ... -
#实践笔记#Ubuntu配置Apache+PHP+MySQL
2015-03-01 20:50 533http://www.jb51.net/article/2 ... -
linux命令
2015-03-01 20:50 594sudo /etc/init.d/apache2 rest ... -
ubuntu下修改文件夹权限
2015-03-01 20:50 647常用方法如下:sudo chm ...
相关推荐
4.Squid 测试安装和配置完成后,启动Squid服务并检查其状态: ```bash sudo systemctl start squid sudo systemctl status squid ``` 5.Squid 常用命令以下是一些Squid的常用管理命令: - `squid -k reconfigure`...
部署的时候要求离线操作,不能联网,所以不能yum install squid来安装squid 于是从网上下了最新版本的squid离线包,进行离线安装,这是我参照了网上的安装方法,解决了安装中的一些问题后,总结出来的安装步骤,以及...
在Linux环境下安装配置Squid,可以按照以下步骤进行: 1. **获取Squid软件包**: 首先,你需要从FTP服务器下载Squid的安装包。在本例中,可以从地址`ftp://168.1.6.23/incoming/bin/`下载名为`squid.tar`的文件。 ...
本文将详细介绍SQUID的基本原理、安装配置步骤及其在Linux环境下的应用。 **SQUID原理** SQUID的核心功能是作为HTTP代理服务器,它通过缓存互联网上的静态内容(如图片、CSS、JavaScript文件等),减少对原始...
在本文中,作者探讨了如何利用Linux操作系统和Squid软件构建一个优化的缓存代理服务器。Squid是一个开源的代理服务软件,允许用户自由使用和修改,常用于提高网络访问速度和效率。在基于Linux的环境中,Squid作为...
1.Net-snmp 获取与安装 2.Net-snmp 的配置 ...2.Squid 获取与安装 3.Squid 配置 4.Squid 测试 5.Squid 常用命令 6.Squid 其他 7.Squid.conf 配置实例 8.Squid.conf 配置说明 9.Squid命中率分析 10.Squid 排错
在本文中,我们将详细介绍如何在Linux系统中安装、配置、卸载Squid,以及安装和配置SNMP(简单网络管理协议)。 **Squid的卸载** 1. 首先,通过`rpm -qa | grep squid`命令检查Squid是否已安装。如果显示Squid的...
4. **安装Squid**:编译完成后,使用`sudo make install`将Squid安装到系统的适当位置。默认情况下,Squid的配置文件(`squid.conf`)会被安装在`/etc/squid`目录下。 5. **配置Squid**:编辑`/etc/squid/squid....
总的来说,Squid在Linux环境中的安装和配置是一个涉及多个层面的过程,包括基础服务的启动、配置文件的定制、网络安全的设置以及性能的优化。熟练掌握这些知识点将有助于有效地管理和使用Squid代理服务。
Linux Squid管理界面是针对Squid网络代理服务器的一个重要工具,它提供了用户友好的图形化界面,使得管理员能够更加方便地管理和配置Squid。Squid是一款广泛使用的开源缓存代理软件,用于提高网络访问速度并降低...
2. **安装与配置**:文档可能会详细讲解在不同操作系统(如Linux)上的安装步骤,以及如何配置Squid的配置文件(`squid.conf`),包括指定缓存目录、设置监听端口、定义访问策略等。 3. **缓存机制**:Squid的缓存...
《Squid中文权威指南》是一本专注于Squid缓存代理服务器的详细教程,旨在帮助读者深入理解和高效使用这款开源软件。Squid作为一款广泛应用于Linux环境的网络代理服务器,其主要功能是提高网络访问速度,节省带宽,...
安装完成后,配置文件`squid.conf`应被放置在指定的目录下,例如`C:\squid\etc\squid.conf`。调试过程包括启动Squid服务,检查日志文件,确保没有错误,并测试代理功能是否正常工作。 六、维护与优化 运行Squid时,...
完成安装后,接下来的关键步骤是根据实际需求对配置文件`/opt/squid/etc/squid.conf`进行适当调整。 1. **配置可见主机名**: - 更改`visible_hostname`配置项,用于指定Squid对外展示的主机名。 - 示例:`...
应用配置后,重启Squid服务使更改生效: ```bash sudo service squid restart # Ubuntu/Debian sudo systemctl restart squid # CentOS/RHEL ``` 二、Squid+ICAP环境搭建 1. 安装ICAP服务器 例如,你可以使用mod_...
一、安装 Squid 1. 下载 Squid 的源代码包:从 http://www.squid-cache.org 下载最新版本的 Squid 源代码包,例如 squid-3.0.PRE4.tar.gz。 2. 解压缩源代码包:使用 tar 命令解压缩源代码包,例如 `# tar xvzf ...
初始化过程会在 `/var/spool/squid/` 目录下创建一系列子目录。 ##### 3.3 Squid 服务的启动与停止 Squid 服务可以通过标准的系统服务管理命令进行操作: - **启动 Squid 服务**:`# service squid start` - **...
《Linux代理服务全攻略——Squid篇》深入解析 Squid是Linux操作系统中广泛使用的代理服务软件,它的主要作用在于提供网络访问控制和优化网络资源利用。代理服务能够帮助那些无法直接连接到Internet的用户进行访问,...
安装完成后,主要配置文件为`/etc/squid/squid.conf`。配置项包括监听端口、缓存目录、访问控制规则等。 四、Squid使用实例 1. **作为透明代理**:通过修改网络设备的配置,使所有流量经过Squid,实现无感知的代理...