shell脚本-LVS节点健康检查
【摘要】 #!/bin/bash
VIP=202.106.195.1
PORT=80
RIP=(192.168.100.10 192.168.100.20)
while true
do
for ((i=0;i<`echo ${#RIP[*]}`;i++))
do code=`curl -I -m 10 -o /dev/null -s -w %{http_code...
#!/bin/bash
VIP=202.106.195.1
PORT=80
RIP=(192.168.100.10 192.168.100.20)
while true
do
for ((i=0;i<`echo ${#RIP[*]}`;i++))
do code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://${RIP[$i]}` if [ $code -ne 200 -a $(ipvsadm -Ln|grep ${RIP[$i]}|wc -l) -eq 1 ] then ipvsadm -d -t $VIP:$PORT -r ${RIP[$i]}:$PORT elif [ $code -eq 200 -a $(ipvsadm -Ln|grep ${RIP[$i]}|wc -l) -lt 1 ] then ipvsadm -a -t $VIP:$PORT -r ${RIP[$i]}:$PORT fi
done
sleep 5
done keepalived 监控服务
#!/bin/bash
while true
do
if [ $(pidof httpd|wc -l) -eq 1 -a $(pidof keepalived|wc -l) -eq 0 ]
then systemctl start keepalived
fi pidof httpd &>/dev/null
if [ $? -ne 0 ]
then systemctl start httpd &>/dev/null
fi
sleep 3 pidof httpd &>/dev/null
if [ $? -ne 0 ]
then systemctl stop keepalived
fi
sleep 3
done
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
文章来源: zmedu.blog.csdn.net,作者:互联网老辛,版权归原作者所有,如需转载,请联系作者。
原文链接:zmedu.blog.csdn.net/article/details/89439191
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)