Skip to content

Instantly share code, notes, and snippets.

@YUChoe
Last active May 7, 2020 00:31
Show Gist options
  • Save YUChoe/d64e22365711a9def359634e9f000735 to your computer and use it in GitHub Desktop.
Save YUChoe/d64e22365711a9def359634e9f000735 to your computer and use it in GitHub Desktop.
ipvs start/stop
#!/bin/bash
usage ()
{
if [ -e $1 ]; then
echo "Usage: $0 {start|stop|status|restart}"
exit
fi
}
start ()
{
. /ucs/policy/lb.conf
# set expired time
# tcp tcpfin udp
ipvsadm --set 900 120 60
# UDP virtual IP
# ipvsadm -A -u $ipaddr:$LSN_PORT -s rr --pe sip -p 120 -o
# ipvsadm -A -u $ipaddr:$LSN_PORT -s rr -p 120 -o
ipvsadm -A -u $ipaddr:$LSN_PORT -s rr -p 120
# UDP instances
for i in $(seq 1 $icnt)
do
ipvsadm -a -u $ipaddr:$LSN_PORT -r $ipaddr:$(($INS_PORT_START + $i - 1)) -m -w 1
done
# TCP virtual IP
ipvsadm -A -t $ipaddr:6061 -s rr -p 120
#TCP instances
for i in $(seq 1 $icnt)
do
ipvsadm -a -t $ipaddr:6061 -r $ipaddr:$(($INS_PORT_START + $i - 1)) -m -w 1
done
}
stop ()
{
ipvsadm -C
}
restart ()
{
stop
start
}
status ()
{
echo
echo "# LoadBalancer Real/Virtual Ststus"
ipvsadm -ln | egrep -v "IP Virtual Server|IPVS"
echo
echo "# LoadBalancer Connection entries"
ipvsadm -lcn | egrep -v "IP Virtual Server|IPVS"
}
case "$1" in
stop) stop ;;
status) status ;;
start|restart|reload|force-reload) restart ;;
*) usage ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment