LVS DR模式有没有简单的脚本监测real service的在线情况。
根据监测在线情况修改规则。
Anonymous (没有被验证)
周一, 2015-03-02 03:09
Permalink
# vim auto_lvs.sh #!/bin/bash VIP=192.168.1.253:80 checkserver=$(awk '/192.168.1.253:80/&& NR>1 {print $5}' /etc/sysconfig/ipvsadm) while : do for i in $checkserver do rev=$(elinks -dump http://$i/index.html 2> /dev/null | grep -o uplooking) if [ "$rev" = uplooking ] then ipvsadm -l -n | grep "$i" rev1=$? [ $rev1 -ne 0 ] && ipvsadm $(grep $i /etc/sysconfig/ipvsadm) else ipvsadm -d -t $VIP -r "$i" fi done sleep 10s - -每10s检查一次 done #chmod +x auto_lvs.sh #nohup /bin/bash auto_lvs.sh & --nohup不随主机的bash窗口而停止执行 #echo 'nohup /bin/bash auto_lvs.sh &' >> /etc/rc.local
There are currently 0 users online.
Anonymous (没有被验证)
周一, 2015-03-02 03:09
Permalink
可以实现,如下脚本
# vim auto_lvs.sh
#!/bin/bash
VIP=192.168.1.253:80
checkserver=$(awk '/192.168.1.253:80/&& NR>1 {print $5}' /etc/sysconfig/ipvsadm)
while :
do
for i in $checkserver
do
rev=$(elinks -dump http://$i/index.html 2> /dev/null | grep -o uplooking)
if [ "$rev" = uplooking ]
then
ipvsadm -l -n | grep "$i"
rev1=$?
[ $rev1 -ne 0 ] && ipvsadm $(grep $i /etc/sysconfig/ipvsadm)
else
ipvsadm -d -t $VIP -r "$i"
fi
done
sleep 10s - -每10s检查一次
done
#chmod +x auto_lvs.sh
#nohup /bin/bash auto_lvs.sh & --nohup不随主机的bash窗口而停止执行
#echo 'nohup /bin/bash auto_lvs.sh &' >> /etc/rc.local