LVS-DR配置

LVS/DR 配置

三台机器:

director(eth0192.168.31.166, vip eth0:0:192.168.31.110)

real server1(eth0 rip: 192.168. 31.100, viplo:0: 192.168.31.110)

real server2(eth0 rip: 192.168.31.101, viplo:0: 192.168.31.110)


Director  vim/usr/local/sbin/lvs_dr.sh 

//增加 

#! /bin/bash

echo 1 > /proc/sys/net/ipv4/ip_forward

ipv=/sbin/ipvsadm

vip=192.168.31.110

rs1=192.168.31.100

rs2=192.168.31.101

ifconfig eth0:0 $vip broadcast $vip netmask255.255.255.255 up

route add -host $vip dev eth0:0

$ipv -C

$ipv -A -t $vip:80 -s rr

$ipv -a -t $vip:80 -r $rs1:80 -g -w 1

$ipv -a -t $vip:80 -r $rs2:80 -g -w 1

 

 

两台rs上:

vim /usr/local/sbin/lvs_dr_rs.sh

#! /bin/bash

vip=192.168.31.110

ifconfig lo:0 $vip broadcast $vip netmask255.255.255.255 up

route add -host $vip 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

 

 

然后director上执行: bash /usr/local/sbin/lvs_dr.sh

两台rs上执行: bash /usr/local/sbin/lvs_dr_rs.sh

Windows下浏览器测试访问




本文转自 sykmiao 51CTO博客,原文链接:http://blog.51cto.com/syklinux/1741457,如需转载请自行联系原作者
上一篇:Redis学习--AOF日志重写触发场景


下一篇:二分查找模板代码总结