lvs

#!/bin/bash

#

vip=10.1.0.5

mask='255.255.255.255'

case $1 in

start)

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce

ifconfig lo:0 $vip netmask $mask broadcast $vip up

route add -host $vip dev lo:0

;;

stop)

ifconfig lo:0 down

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce

echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce

;;

*) 

echo "Usage $(basename $0) start|stop"

exit 1

;;

esac

VS的配置脚本:

#!/bin/bash

#

vip='10.1.0.5'

iface='eno16777736:0'

mask='255.255.255.255'

port='80'

rs1='10.1.0.7'

rs2='10.1.0.8'

scheduler='wrr'

type='-g'

case $1 in

start)

ifconfig $iface $vip netmask $mask broadcast $vip up

iptables -F

ipvsadm -A -t ${vip}:${port} -s $scheduler

ipvsadm -a -t ${vip}:${port} -r ${rs1} $type -w 1

ipvsadm -a -t ${vip}:${port} -r ${rs2} $type -w 1

;;

stop)

ipvsadm -C

ifconfig $iface down

;;

*)

echo "Usage $(basename $0) start|stop"

exit 1

;;

esac

原创文章,作者:15152188070,如若转载,请注明出处:http://www.178linux.com/55076

(0)
1515218807015152188070
上一篇 2016-10-27
下一篇 2016-10-27

相关推荐