centos mysql lvs_针对于lvs分发mysql的监控

#!/bin/bash

c=`cat /opt/duoyongtu/10/mysql.txt`

for i in $c

do

a=`mysql -uroot -h$i -p12345678 -P3306 -e "show slave status\G"|egrep '(Slave_IO_Running|Slave_SQL_Running)'|awk '{print $NF}'`

for k in $a

do

if [ "$k" != "Yes" ]; then

f=`ssh 192.168.0.146 "ip a|grep 192.168.1.5|wc -l"`

if [ "$f" -eq 1 ]; then

b=`ssh 192.168.0.146 "cat /opt/yanchao/xianzai.txt| wc -l"`

if [ "$b" -ge 2 ]; then

ssh $i "iptables -A INPUT -s 192.168.0.146 -p tcp -m tcp --dport 3306 -j DROP"

ssh $i "iptables -A INPUT -s 192.168.0.147 -p tcp -m tcp --dport 3306 -j DROP"

echo bad

else

echo good

fi

else

b=`ssh 192.168.0.147 "cat /opt/yanchao/xianzai.txt| wc -l"`

if [ "$b" -ge 2 ]; then

ssh $i "iptables -A INPUT -s 192.168.0.146 -p tcp -m tcp --dport 3306 -j DROP"

ssh $i "iptables -A INPUT -s 192.168.0.147 -p tcp -m tcp --dport 3306 -j DROP"

echo bad

else

echo good

fi

fi

else

d=`ssh $i "iptables -L -n|grep 192.168.0.146|wc -l"`

if [ "$d" -ge 1 ]; then

for e in 192.168.0.146 192.168.0.147

do

ssh $i "iptables -F"

done

fi

fi

done

done

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值