linux企业部分 varnish

来源:互联网 发布:什么软件测八卦 编辑:程序博客网 时间:2024/06/05 13:30

#############varnish##########

在server1主机上配置varnish

1.安装

yum install varnish-3.0.5-1.el6.x86_64.rpmvarnish-libs-3.0.5-1.el6.x86_64.rpm -y


2.配置varnish配置文件

vim /etc/varnish/default.vcl

设置两个不同域名站点后端服务器服务端ip 与端口

 

查看缓存命中情况


当访问 www.westos.org 域名时从 web1 上取数据,访问 bbs.westos.org 域名时到 web2 取数据,访问其他页面报错

 

其中return (pass)为是否直接清空缓存

lb代表负载均衡模式


 

vim /etc/sysconfig/varnish

设置varnish端口为80

 

 

3.在server2服务端中

开启http服务

 

vim /etc/httpd/conf/httpd.conf

开启http端口80

 

并写入www.westos.org 与bbs.westos.org地址

 

写入index.html文件


 

/etc/init.d/httpd restart

因为设置在server3中不用做lb负载均衡,因此除了写入主配置文件地址不用做,其他与server2中所作相同

3.在测试主机中配置本地解析

Vim /etc/hosts


4,测试

 

 

##########cdn推送页面#########

1.文件操作

将bansys.zip文件解压到指定目录

Yum install unzip -y

unzip -d /var/www/html bansys.zip


解压后移动到html/目录下


yum install php -y

Vim /etc/httpd/conf/httpd.conf

将server1 http端口改为8080


2.设置cdn推送界面

 

此时在浏览器输入172.25.1.1:8080可显示cdn推送界面

 

3.配置varnish配置文件
vim /etc/varnish/default.vcl
 
 
/etc/init.d/varnish reload
在server2 server3服务端中开启apache服务
4.测试
 
每在浏览器中推送一次/index.html, curl www.westos.org/index.html会刷新一次



原创粉丝点击