实验规划说明:
Director两块网卡,IP地址分配如下:
1.本地公网IP(eth0):192.168.112.101
2.vip(eth1:1):192.168.112.100
3.dip(eth1):192.168.201.7
Realsever1两块网卡,IP地址分配如下:
1.rip(eth0):192.168.201.8
2.vip(lo:0):192.168.112.100
3.本地IP(eth1):192.168.112.8 //通过该IP以便从Realsever1可以访问Client.
Realsever2两块网卡,IP地址分配如下:
1.rip(eth0):192.168.201.9
2.vip(lo:0):192.168.112.100
3.本地IP(eth1):192.168.112.9 //通过该IP以便从Realsever1可以访问Client.
具体步骤如下:
1.配置realserver1的网络参数:
sysctl -p net.ipv4.conf.all.arp_ingore=1
sysctl -p net.ipv4.conf.eth0.arp_ingore=1
sysctl -p net.ipv4.conf.all.arp_announce=2
sysctl -p net.ipv4.conf.eth0.arp_announce=2
sysctl -p net.ipv4.ip_forward=1
若要上述信息永久生效需要写入/etc/sysctl.conf的配置文件.
ifconfig lo:0 192.168.112.100 broadcast 192.168.112.100 netmask 255.255.255.255 up
若要上述信息永久生效需要写入/etc/sysconfig/network-scripts/ifcfg-lo0的配置文件.
route add -host 192.168.112.100 dev lo:0
2.配置realserver2的网络参数:
sysctl -p net.ipv4.conf.all.arp_ingore=1
sysctl -p net.ipv4.conf.eth0.arp_ingore=1
sysctl -p net.ipv4.conf.all.arp_announce=2
sysctl -p net.ipv4.conf.eth0.arp_announce=2
sysctl -p net.ipv4.ip_forward=1
若要上述信息永久生效需要写入/etc/sysctl.conf的配置文件.
ifconfig lo:0 192.168.112.100 broadcast 192.168.112.100 netmask 255.255.255.255 up
若要上述信息永久生效需要写入/etc/sysconfig/network-scripts/ifcfg-lo0的配置文件.
route add -host 192.168.112.100 dev lo:0
3.配置director服务器:
sysctl -p net.ipv4.ip_forward=1
若要上述信息永久生效需要写入/etc/sysctl.conf的配置文件.
ifconfig eth1:1 192.168.112.100 broadcast 192.168.112.100 netmask 255.255.255.255 up
route add -host 192.168.112.100 dev eth1:1
4.配置lvs.
[root@mytest ~]# ipvsadm -A -t 192.168.112.100:80 -s rr
[root@mytest ~]# ipvsadm -a -t 192.168.112.100:80 -r 192.168.201.8 -g
[root@mytest ~]# ipvsadm -a -t 192.168.112.100:80 -r 192.168.201.9 -g
[root@mytest ~]# 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.112.100:80 rr
-> 192.168.201.8:80 Route 1 0 0
-> 192.168.201.9:80 Route 1 0 0
5.使用浏览器进行测试:
6.查看状态:
[root@mytest ~]# ipvsadm -Ln --stats
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Conns InPkts OutPkts InBytes OutBytes
-> RemoteAddress:Port
TCP 192.168.112.100:80 53 271 0 28193 0
-> 192.168.201.8:80 27 140 0 13983 0
-> 192.168.201.9:80 26 131 0 14210 0
7.至此,基于2个网段的LVS的DR模型测试完成.
本文出自 “webseven” 博客,请务必保留此出处http://webseven.blog.51cto.com/4388012/1549807
原文地址:http://webseven.blog.51cto.com/4388012/1549807