模型二:DR模型的配置
实验环境:
采用VMware虚拟机,版本6.0.5
操作系统:Red Hat Enterprise Linux 5 (2.6.18)
虚拟机1:Director:
DIP配置在接口上 192.168.1.59
VIP配置在接口别名上:192.168.1.100
虚拟机1:RS1:RIP配置在接口上:172.16.19.60 ;VIP配置在lo别名上
虚拟机2:RS2:RIP配置在接口上:172.16.19.61 ;VIP配置在lo别名上
# Director配置
[root@localhost ~]#setup
[root@localhost ~]# ifconfig eth0:0 192.168.1.100 broadcast 192.168.1.1
netmask 255.255.255.255 up
[root@localhost ~]# ifconfig
[root@localhost ~]# route add -host 192.168.1.100 dev eth0:0
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
192.168.1.100 * 255.255.255.255 UH 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
# 在Director上配置Ipvs
[root@localhost ~]# yum install ipvsadm -y
[root@localhost ~]# ipvsadm -A -t 192.168.1.100:80 -s wlc
[root@localhost ~]# ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.60 -g -w 2
[root@localhost ~]# ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.61 -g -w 4
[root@localhost ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.100:80 wlc
-> 192.168.1.61:80 Route 4 0 0
-> 192.168.1.60:80 Route 2 0 0
# RS1和RS2配置
定义内核参数,禁止响应对VIP的ARP广播请求
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[root@localhost ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[root@localhost ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
# 配置VIP
[root@localhost ~]# ifconfig lo:0 192.168.1.100 broadcast 192.168.1.1
netmask 255.255.255.255 up
[root@localhost ~]# ifconfig
# 凡是到192.168.1.100主机的一律使用lo:0响应
[root@localhost ~]# route add -host 192.168.1.100 dev lo:0
[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
192.168.1.100 * 255.255.255.255 UH 0 0 0 lo
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
[root@localhost ~]# yum install httpd -y
# 在RS1上配置网页
echo "<h1>RealServer1</h>" > /var/www/html/index.html
[root@localhost ~]# service httpd start
Starting httpd: [ OK ]
# 在RS2上配置网页
echo "<h1>RealServer2</h>" > /var/www/html/index.html
[root@localhost ~]# service httpd start
Starting httpd: [ OK ]
我们通过物理机对192.168.1.100访问查看wlc算法的实现结果
#在 Director 上查看
[root@localhost ~]# ipvsadm -Ln