安装
sh hot-varnish-1.0.0.sh
hot-varnish-1.0.0
如果和Web在一台机上,先停止Web Server 然后把Web Server 改个端口 比如81或者8080 如果不在一台机上就不用了
Ip为后端Ip 和Web在一起就写127.0.0.1
port为web的端口,本机你改成81就写81 改成8080就写8080 不在1台机上就写后端的Web端口
domain 域名,你要缓存的域名,最后一个是管理端口,用来清理缓存的
安装完就把域名解析到安装varnish机器的Ip上,访问域名就看到你原来的站点了
/wwwroot/varnish/logs 日志目录,切割脚本已经带了
/wwwroot/vcache 缓存目录
www:www 运行用户和组
/usr/local/varnish 安装路径
/usr/local/varnish/etc/varnish/vhost.vcl
配置文件
启动在/etc/rc.local里,关闭直接K掉进程就行
varnish只能放在web前面
如果用varnish负载 反带 加缓存
backend web01 {
.host = "192.168.10.244";
.port = "80";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
backend web02 {
.host = "192.168.10.243";
.port = "80";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
backend web03 {
.host = "192.168.10.242";
.port = "80";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
director load round-robin {
{
.backend = web01;
}
{
.backend = web02;
}
{
.backend = web03;
}
}
