---------------------DR模式调度器配置------(调度器与各服务器在同个网段内)-------------
------------------注意:80.188是调度器和各真实服务器要共同虚拟出的一个地址---------------
[root@lss ~]# vi dr.sh
#!/bin/bash
#
ifconfig ens33:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
route add -host 192.168.80.188 dev ens33:0
ipvsadm -C
ipvsadm -A -t 192.168.80.188:80 -s rr
ipvsadm -a -t 192.168.80.188:80 -r 192.168.80.101:80 -g
ipvsadm -a -t 192.168.80.188:80 -r 192.168.80.102:80 -g
ipvsadm –Ln
[root@lss ~]# sh dr.sh
[root@lss ~]# ifconfig
192.168.80.101服务器:
Vmnet1内网:192.168.80.101
[root@lss01 ~]# yum install -y httpd
[root@lss01 ~]# vi /etc/httpd/conf/httpd.conf
ServerName www.aa.com
[root@lss01 ~]# vi /var/www/html/index.html
<h1>Server aa </h1>
[root@lss01 ~]# service httpd restart
------DR模式,各真实服务器配置---虚拟地址是相同的---
[root@lss01 ~]# vi web.sh
#!/bin/bash
#haha
ifconfig lo:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
route add -host 192.168.80.188 dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p &>/dev/null
[root@lss01 ~]# sh web.sh
[root@lss01 ~]# ifconfig
192.168.80.102服务器:
Vmnet1内网:192.168.80.102
[root@lss02 ~]# yum install -y httpd
[root@lss02 ~]# vi /etc/httpd/conf/httpd.conf
ServerName www.bb.com
[root@lss02 ~]# vi /var/www/html/index.html
<h1>Server bb </h1>
[root@lss02 ~]# service httpd restart
------DR模式,各真实服务器配置---虚拟地址是相同的---
[root@lss02 ~]# vi web.sh
#!/bin/bash
#haha
ifconfig lo:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 up
route add -host 192.168.80.188 dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p &>/dev/null
[root@lss02 ~]# sh web.sh
真机浏览器测试:
Vmnet1:192.168.80.88
浏览器输入:http://192.168.80.188/会轮流出现192.168.80.101和192.168.80.102的页面
友情链接地址:负载均衡群集之—LVS-NAT http://blog.51cto.com/13572519/2084181
原文地址:http://blog.51cto.com/13572519/2084197