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

Linux服务器
用Ubuntu做WEB服务器相关设置
使用Linux的rsync命令实现 多服务器镜像同步
Linux环境下Apache与Tomcat共存
Linux下简单的DNS实例一则
linux系统SendMail详细配置
实现Linux操作系统下DNS服务器的搭建
使用nbspNginxnbsp提升网站访问速度
使用awstats分析Nginx的访问日志
Linux网络中DHCP和DNS服务快速整合
Nginx负载均衡搭建胜过Apache十倍
Linux应用 DHCP服务器的安装和故障排除
ubuntu一步架设ftp服务器图文讲解
DHCP概述及Linux DHCP服务器的配置
Linux集群技术中的热点---虚拟技术
Linux操作系统的防火墙配置:基础篇
Linux DHCP服务器的配置
4步用XAMPP快速搭建LAMP环境
简略讲解对 Linux 服务器的四种入侵级别
浅谈Linux优化及安全配置的个人体会
解读Linux文件权限的设置方法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-18   浏览: 91 ::
收藏到网摘: 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]