分类: 服务器与存储
2015-08-04 10:06:03
配置super63
配置IP
DIP eth0
192.168.1.70
VIP eth0:1
192.168.1.63
网关指向192.168.1.1
配置LVS-DR 规则(实验以轮询rr的方式)
[root@super63 network-scripts]# ipvsadm -A -t 192.168.1.63:80 -s rr
[root@super63 network-scripts]# ipvsadm -a -t 192.168.1.63:80 -r 192.168.1.65 -g
[root@super63 network-scripts]# ipvsadm -a -t 192.168.1.63:80 -r 192.168.1.66 –g
[root@super63 network-scripts]# ipvsadm -L -n #查看
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port
Forward Weight ActiveConn InActConn
TCP
192.168.1.63:80 rr
-> 192.168.1.65:80
Route 1 0
0
-> 192.168.1.66:80
Route 1 0
0
配置super65
配置IP
etho
192.168.1.65/24
lo:1 192.168.1.63 255.255.255.255
网关指向192.168.1.1
关闭ARP转发 #使机器只响应eth0
[root@super65~]#echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
[root@super65 ~]#echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce
写入配置文件
[root@super65 network-scripts]# vim /etc/sysctl.conf
#尾部追加
net.ipv4.conf.eth0.arp_ignore
= 1
net.ipv4.conf.eth0.arp_announce = 2
[root@super65 network-scripts]# sysctl -p
安装apache在apache服务器主页上写入内容便于测试
[root@super65 ~# ]echo "192.168.1.65" > /var/www/html/index.html
配置super66 #方法与super65原理一样
测试:
super64模拟客户机访问vip
[root@super64 ~]# elinks 192.168.1.63 --dump
192.168.1.65
[root@super64 ~]# elinks 192.168.1.63 --dump
192.168.1.66
[root@super64 ~]# elinks 192.168.1.63 --dump
192.168.1.65
可以看到每次访问vip时访问了不同页面,负载均衡实现。