您的位置:首页 > 其它

varnishd安装与配置

2015-10-10 18:04 204 查看
https://www.varnish-cache.org/releases
# wget https://repo.varnish-cache.org/source/varnish-3.0.7.tar.gz
# tar xvzf varnish-3.0.7.tar.gz
# cd varnish-3.0.7
./configure --prefix=/usr/local/varnish PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# make && make install
报错:
varnishadm.c:48:33: error: editline/readline.h: No such file or directory
yum install *readline-devel*
yum install libedit libedit-dev*
安装成功后,安装的目录是
cd /usr/local/varnish/sbin
./varnishd -V
查看版本,看是否安装成功
配置文件
/usr/local/varnish/etc/varnish/default.vcl
这个对的:
/usr/local/varnish/sbin/varnishd -a :82 -b 127.0.0.1:80 -p thread_pool_max=1500 -p thread_pools=5 -p listen_depth=512  -w 1,10000,120
这个也可以
/usr/local/varnish/sbin/varnishd -a :82 -f /usr/local/varnish/etc/varnish/default.vcl -s malloc,1024m  -w 1,10000,120
这个不行
/usr/local/varnish/sbin/varnishd -f /usr/local/varnish/etc/varnish/default.vcl -s malloc,1024m  -a :82 -T 127.0.0.1:81
groupadd -g www
useradd -g www www
mkdir -p /var/vcache
chown -R www:www /var/vcache
/usr/local/varnish/sbin/varnishd -n /var/vcache -f /usr/local/varnish/etc/varnish/default.vcl -a 0.0.0.0:80 -s file,/var/vcache/varnish_cache.data,1G -g www -u www -w 30000,51200,10 -T 127.0.0.1:82
各参数的含义如下:
-f 指定 varnish 的配置文件位置
-s 指定 varnish 缓存存放的方式,常用的方式有:“-s file,<dir_or_file>,<size>”。
-T address:port 设定 varnish 的 telnet 管理地址及其端口
-a address:port 表示 varnish 对 http 的监听地址及其端口
-t 默认TTL
-w 最小线程,最大线程,超时时间
http://blog.csdn.net/keda8997110/article/details/8777153
http://www.tuicool.com/articles/6rA32a

需要注意的是varnish返回的响应,varnish会增加三个相应头信息,分别是“X-Varnish”、“Via”和“Age”。这些头信息在Varnish的处理过程中非常有用。X-Varnish头信息的后面会有一个或两个数字,如果是一个数字,就表明varnish在缓存中没有发现这个请求,这个数字的含义是varnish为这个请求所做的标记ID。如果X-Varnish后是两个数字,就表明varnish在缓存中命中了这个请求,第一个数字是请求的标识ID,第二个数字是缓存的标识ID。“Via”头信息表明这个请求将经过一个代理。“Age”头信息标识出这个请求将被缓存多长时间(单位:秒)。首次请求的“Age”为0,后续的重复请求将会使Age值增大。如果后续的请求没有是“Age”增加,那就说明varnish没有缓存这个响应的结果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: