Varnish[反向代理,缓存基于内存或文件]

下载软件包:http://pan.baidu.com/s/1nuCfCud
#tar -xf lnmp_soft-2016-7-20.tar.gz
#cd lnmp_soft
#install_lnmp.sh  选择7
配置文件:
主配置文件(定义前端配置)
#vim /etc/sysconfig/varnish
60:VARNISH_VCL_CONF=/etc/varnish/default.vcl #vcl文件路径
66:ARNISH_LISTEN_PORT=80  端口
73:VARNISH_SECRET_FILE=/etc/varnish/secret 密钥文件(secretfile)
76:VARNISH_MIN_THREADS=50最小线程数
79:VARNISH_MAX_THREADS=1000 最大
89:VARNISH_STORAGE_SIZE=64M 缓存大小
92:VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
使用内存缓存页面,内存大小为64M
+++++++++++++++++++++++++++++++++++++++++++++
主配置文件(定义后台服务器)
#vim /etc/varnish/default.vcl
backend default {
     .host = "192.168.2.100";
     .port = "80";
 }
密码文件
#uuidgen > /etc/varnish/secret
#service  varnish start
+++++++++++++++++++++++++++++++++++
如何管理varnish的缓存内容
+++++++++++++++++++++++++++++++++++++++++++++++++++++
清除缓存内容的命令格式:
varnishadm -T IP:Port -S secretfile  ban.url b.html
查看缓存清理列表:
varnishadm bin.list
++++++++++++++++++++++++++++++++++++++++++
Varnish日志:
varnishlog [-w file] #共享内存的日志
varnishncsa  [-w file] #类似Apache日志
+++++++++++++++++++++++++++++++++++++++++++++
Varnish状态:
varnishstat (/usr/local/varnish/bin/varnishstat)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Client connections accepte  客户端成功发送链接总数量
Client requests received   客户发送HTTP请求总数
cache_hit - Cache hits     !重要:命中缓存的次数
cache_miss - Cache misses  !重要:缓存非命中的次数
N struct object         表示当前被缓存的数量
N expired objects       表示过期的缓存内容数量
N LRU moved objects     表示被淘汰的缓存内容个数
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
如何管理varnish的缓存内容
1.修改Apache页面
#echo "ccc" > /var/www/html/b.html
2.客户端访问代理(获取旧的页面内容)
3.代理(链接/usr/local/varnish/bin)
#varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret  ban.url b.html
4.客户端再访问,获取新的页面内容