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下浏览器测试访问


你可能感兴趣的:(server,LVS,Director)