标签:src var forward rem 浏览器 https server images 缓存
NFS:192.168.30.33
WEB1:192.168.30.17
WEB2:192.168.30.27
LVS:192.168.30.7 VIP:10.0.0.100
DNS:172.20.42.27
Mysql:192.168.30.30
Route:192.168.30.208, 10.0.0.200,172.20.42.200
Client: Windows IP 172.20.42.222
1. 网络
ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.30.17
PREFIX=24
GATEWAY=192.168.30.208
ifcfg-eth0:1
DEVICE=eth0:1
IPADDR=10.0.0.100
PREFIX=8
2. 安装相应的包
yum install httpd php-fpm php-mysql -y
3. 在RS上修改内核参数以限制arp通告及应答级
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
参考WEB1,只是将IP更改为192.168.30.27
1. 安装 yum install bind -y
2. 配置
vim /etc/named.rfc1912.zones
zone "blog.com" IN {
type master;
file "blog.com.zone";
};
vim /var/named/blog.com.zone
$TTL D
@ IN SOA master.blog.com admin.blog.com. (
0 ; serial
D ; refresh
H ; retry
W ; expire
H ) ; minimum
NS master
master A 172.20.42.27
www A 10.0.0.100
3. 启动systemctl restart named
1. 网络
ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.30.208
PREFIX=24
ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
IPADDR=10.0.0.200
PREFIX=8
ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
IPADDR=172.20.42.200
PREFIX=16
2. 启用ip_forward
echo 1 > /prov/sys/net/ipv4/ip_forward
sysctl -a |grep ip_forward: net.ipv4.ip_forward = 1
1. 网络
ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.30.7
PREFIX=24
GATEWAY=192.168.30.208
ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
IPADDR=10.0.0.100
PREFIX=8
2. 运行如下的脚本(适当进行更改)
[root@lvs ~]#cat lvs_dr_vs.sh
#!/bin/bash
#Author:wangxiaochun
#Date:2017-08-13
vip=‘10.0.0.100‘
iface=‘eth0:1‘
mask=‘255.255.255.255‘
port=‘80‘
rs1=‘192.168.30.17‘
rs2=‘192.168.30.27‘
scheduler=‘wrr‘
type=‘-g‘
rpm -q ipvsadm &> /dev/null || yum -y install ipvsadm &> /dev/null
case $1 in
start)
ifconfig $iface $vip netmask $mask #broadcast $vip up
iptables -F
ipvsadm -A -t ${vip}:${port} -s $scheduler
ipvsadm -a -t ${vip}:${port} -r ${rs1} $type -w 1
ipvsadm -a -t ${vip}:${port} -r ${rs2} $type -w 1
echo "The VS Server is Ready!"
;;
stop)
ipvsadm -C
ifconfig $iface down
echo "The VS Server is Canceled!"
;;
*)
echo "Usage: $(basename $0) start|stop"
exit 1
;;
esac
3. 查看ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 wrr
-> 192.168.30.17:80 Route 1 0 0
-> 192.168.30.27:80 Route 1 0 0
4. 更改lvs-dr的调度策略
ipvsadm -C
ipvsadm -A -t 10.0.0.100:80 -s rr
ipvsadm -a -t 10.0.0.100:80 -r 192.168.30.17
ipvsadm -a -t 10.0.0.100:80 -r 192.168.30.27
5. 测试新的策略
在Linux客户机上,配置网络
DEVICE=eth2
BOOTPROTO=none
IPADDR=172.20.0.7![](https://images2018.cnblogs.com/blog/1386066/201807/1386066-20180703114658714-1685106874.png)
PREFIX=16
GATEWAY=172.20.42.200
DNS1=172.20.42.27
[root@centos7 ~]# curl www.blog.com
web1
[root@centos7 ~]# curl www.blog.com
web2
[root@centos7 ~]# curl www.blog.com
web1
[root@centos7 ~]# curl www.blog.com
web2
测试结论:达到了roundrobin轮询的效果
6. 在windows PC上测试
在浏览器中访问www.blog.com,可以看出,不是每次刷新网站都会切换网站,是因为浏览器的缓存导致。
标签:src var forward rem 浏览器 https server images 缓存
原文地址:https://www.cnblogs.com/liangjindong/p/9257015.html