LVS & realserve 启动脚本

#!/bin/bash
#LVS-dr.sh
vip=192.168.1.254
rip1=192.168.1.1
rip2=192.168.1.2
START(){
ifconfig eth0:vip ${vip}/32 up
ipvsadm -C
ipvsadm -A -t ${vip}:80 -s rr
ipvsadm -a -t ${vip}:80 -r ${rip1} -g
ipvsadm -a -t ${vip}:80 -r ${rip2} -g
ipvsadm
}
STOP() {
ifconfig eth0:vip down
ipvsadm -C
}
STATUS() {
watch ipvsadm -ln
}
case $1 in
start)
START
;;
stop)
STOP
;;
status)
STATUS
;;
*)
echo "Usage: $0 neeg argument [start|stop|status]"
;;
esac


#!/bin/bash
#real_server.sh
vip=192.168.5.254
open() {
ifconfig lo:vip ${vip}/32 up
sysctl -w net.ipv4.conf.lo.arp_announce=2
sysctl -w net.ipv4.conf.lo.arp_ignore=1
sysctl -w net.ipv4.conf.all.arp_announce=2
sysctl -w net.ipv4.conf.all.arp_ignore=1
}
close() {
ifconfig lo:vip down
sysctl -w net.ipv4.conf.lo.arp_announce=0
sysctl -w net.ipv4.conf.lo.arp_ignore=0
sysctl -w net.ipv4.conf.all.arp_announce=0
sysctl -w net.ipv4.conf.all.arp_ignore=0
}
case $1 in
start)
open
;;
stop)
close
;;
*)
echo "Usage: $0 need argument [start|stop]"
;;
esac

你可能感兴趣的:(LVS)