#!/bin/bash
# chkconfig: 2345 10 90
# description: lvs+kepalived realserver.sh
VIP=192.168.236.30
. /etc/rc.d/init.d/functions
case "$1" in
start)
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
ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
sysctl -p > /dev/null 2>&1
echo "realserver start OK"
;;
stop)
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
ifconfig lo:0 down
/sbin/route del $VIP > /dev/null 2>&1
echo "realserver stoped"
;;
*)
echo "Usage:$0 {start|stop}"
exit 1
esac
exit 0
lvs+keepalived 负载均衡realserver.sh脚本
最新推荐文章于 2024-08-14 13:38:16 发布
本文详细介绍了如何使用LVS和Keepalived创建高可用的负载均衡解决方案,并提供了一个名为realserver.sh的关键脚本的解析,该脚本用于管理后端服务器的添加和移除,确保服务的稳定和高效运行。
摘要由CSDN通过智能技术生成