当前位置: 首页 > 图文教程 > 服务器 > Linux服务器 > 搭建性能比Squid高很多的Varnish服务器

Linux服务器
linux下用cron定时执行任务的方法
.htaccess绑定域名到子目录的方法
linux apache下虚拟主机配置方法
apache 局域网访问配置方案
linux Apache服务器系统安全设置与优化
linux中mac地址绑定方法
linux托盘不断闪烁之解决方法
Apache配置 虚拟转向实例
Apache No space left on device的解决办法
Apache rewrite的重写相关的参数说明
LINUX入门级常用命令20条整理
Ubuntu设置开机自动挂载所有格式硬盘分区
5个可能被你忽略的Linux安全设置方法
学习Apache的mod rewrite、access写法
改版时保留原链接,创建新的URL的方法
rsync中文手册之使用rsync实现网站镜像和备份linux
rsync 数据同步使用详解
linux URL的301重定向代码分析
eclipse3.2.2 + MyEclipse5.5 + Tomcat5.5.27 配置数据库连接池
Apache服务器二级域名的完美实现

Linux服务器 中的 搭建性能比Squid高很多的Varnish服务器


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-18   浏览: 119 ::
收藏到网摘: n/a

Arnish是一款高性能的开源HTTP加速器,挪威最大的在线报纸VerdensGang(http://www.vg.no)使用3台Varnish代替了原来的12台squid。性能比以前更好。varnish的作者Poul-HenningKamp是FreeBSD的内核开发者之一,他认为现在的计算机比起1975年已经复杂许多。在1975年时,储存媒介只有两种:内存与硬盘。但现在计算机系统的内存除了主存外,还包括了cpu内的L1、L2,甚至有L3快取。硬盘上也有自己的快取装置,因此squidcache自行处理物件替换的架构不可能得知这些情况而做到最佳化,但操作系统可以得知这些情况,所以这部份的工作应该交给操作系统处理,这就是Varnishcache设计架构。1.下载源码包编译安装:cd/usr/local/src&&wgethttp://nchc.dl.sourceforge.net/s...arnish-1.1.1.tar.gztarzxvf/usr/local/src/varnish-1.1.1.tar.gzcd/usr/local/src/varnish-1.1.1./autogen.sh./configure--enable-debugging-symbols--enable-developer-warnings--enable-dependency-tracking注:如果你的gcc版本是4.2.0或更高的版本,可以加上--enable-extra-warnings编译参数,在出错时,得到附加的警告信息。我这里是用源码包安装的,如果你是redhat或centos可以用rpm包来安装(rpm下载位置:http://sourceforge.net/project/showfiles.php?group_id=155816&package_id=173643&release_id=533569).2.建立cache目录:mkdir-p/cache/varnish/V&&chown-Rnobody:nobody/cache3.编写启动文件:cd/usr/local/varnish/sbinvistart.sh内容如下:#!/bin/sh#file:go.shdate-u/usr/local/varnish/sbin/varnishd\-a10.0.0.129:80\-sfile,/cache/varnish/V,1024m\-f/usr/local/varnish/sbin/vg.vcl.default\-pthread_pool_max=1500\-pthread_pools=5\-plisten_depth=512\-pclient_http11=on\注:-a是指定后端服务器的ip或hostname,就象squid做reveseproxy时的originserver.不过这个也可以在vcl里面写。-f是指定所用的vcl的文件。-s指定cache目录的存储类型,文件位置和大小。-p是指定varnish的启动的一些启动参数,可以根据自己的机器配置来优化varnish的性能。其他参数已经参数的具体含义可以用varnishd--help来查看。

4.编写vcl:我的vcl如下:backenddefault{setbackend.host="127.0.0.1";setbackend.port="http";}#我用的是一台机器做测试,使用的backend用的是127.0.0.1:80.如果varnish机器和后台的机器分开的。写上对应的机器的ip或hostname就可以了。subvcl_recv{if(req.request!="GET"&&req.request!="HEAD"){pipe;}if(req.http.Expect){pipe;}if(req.http.Authenticate||req.http.Cookie){pass;}if(req.request=="GET"&&req.url~"\.(gif|jpg|swf|css|js)$"){lookup;}lookup;}subvcl_pipe{pipe;}subvcl_pass{pass;}subvcl_hash{hash;}subvcl_hit{if(!obj.cacheable){pass;}deliver;}subvcl_timeout{discard;}subvcl_discard{discard;}如果是多个站点在不同的originserver时,可以使用下面配置:backendwww{setbackend.host="www.jackbillow.com";setbackend.port="80";}backendimages{setbackend.host="images.jackbillow.com";setbackend.port="80";}subvcl_recv{if(req.http.host~"^(www.)?jackbillow.com$"){setreq.http.host="www.jackbillow.com";setreq.backend=www;}elsif(req.http.host~"^images.jackbillow.com$"){setreq.backend=images;}else{error404"Unknownvirtualhost";}5.启动varnish:/usr/local/varnish/sbin/start.shMonSep303:13:19UTC2007file/cache/varnish/V/varnish.tEKXXx(unlinked)size1073741824bytes(262144fs-blocks,262144pages)UsingoldSHMFILEpswaux|grepvarnishroot162540.00.011200708?Ss10:430:00/usr/local/varnish/sbin/varnishd-a10.0.0.129:80-s/varnish/V,1024m-f/usr/local/varnish/sbin/vg.vcl.default-pthread_pool_max1500-pthread_pools5-plisten_depth512-pclient_http11onnobody162550.00.111525521808?Sl10:430:00/usr/local/varnish/sbin/varnishd-a10.0.0.129:80-sfile,/cache/varnish/V,1024m-f/usr/local/varnish/sbin/vg.vcl.default-pthread_pool_max1500-pthread_pools5-plisten_depth512-pclient_http11on看到上面信息说明varnish正确启动,恭喜你,你已经配置成功了。

上一页[1][2]