lvs负载均衡后端realserver脚本文件

 OpSky   2017-09-06 17:02   589 人阅读  0 条评论

1、进入指定文件夹:cd /etc/init.d/

2、编辑脚本文件:vi realserver

VIP=192.168.80.20
. /etc/rc.d/init.d/functions
case "$1" in
start)
       ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP
       /sbin/route add -host $VIP dev 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
       echo "RealServer Start OK"
       ;;
stop)
       ifconfig lo:0 down
       route del $VIP >/dev/null 2>&1
       echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
       echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
       echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
       echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
       echo "RealServer Stoped"
       ;;
*)
       echo "Usage: $0 {start|stop}"
       exit 1
esac
exit 0

        这里我们设置虚拟IP为:192.168.80.20

  3、保存脚本文件后更改该文件权限:chmod 755 realserver

  4、开启realserver服务:service realserver start



本文地址:http://www.opsky.top/post/12.html
版权声明:本文为原创文章,版权归 OpSky 所有,欢迎分享本文,转载请保留出处!

评论已关闭!