You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shell-project/os/lvs/lvs-nat-server.sh

25 lines
484 B

#!/usr/bin/bash
VIP=10.9.29.110
REAL_SERVER=(192.168.96.167 192.168.96.168)
WEIGHT=(1 1)
SCHEDULER=wrr
case $1 in
start)
ipvsadm -A -t $VIP:80 -s $SCHEDULER
echo "1" > /proc/sys/net/ipv4/ip_forward
# 设置虚拟服务
for i in ${!REAL_SERVER[@]}
do
ipvsadm -a -t $VIP:80 -r ${REAL_SERVER[$i]}:80 -m -w ${WEIGHT[$i]}
done
;;
stop)
ipvsadm -C
echo "0" > /proc/sys/net/ipv4/ip_forward
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac