q987654 发表于 2019-1-7 12:28:49

监控mysql跟heartbeat的脚本

#!/bin/sh  cat/var/log/mysql_ha.log
  mail -s &quot;mysql and ha warning!server: $DB1IP ha is down&quot; hamgua@gmail.com < /var/log/mysql_ha.log
  fi
  fi
  else
  if [ &quot;$HAPORT&quot; == &quot;694&quot; ];then
  echo &quot;$DB1IP mysql is down,but ha is runing,now shutdown ha,let (DB2IP) to take over mysql,then restart mysql.....&quot; > /var/log/mysql_ha.log
  mail -s &quot;mysql and ha warning!server: $DB1IP mysql is down&quot; hamgua@gmail.com < /var/log/mysql_ha.log
  /etc/rc.d/init.d/heartbeat stop
  /etc/rc.d/init.d/mysqld start
  if [ &quot;$MYPORT&quot; == &quot;3306&quot;];then
  /etc/rc.d/init.d/heartbeat start
  echo &quot;$DB1IP$mysql restart successful,now mysql and ha all running......&quot;
  fi
  else
  echo &quot;$DB1IPmysql and ha all down,first restart msyql,when mysql is run,restart ha&quot;
  /etc/rc.d/init.d/mysqld start
  if [ &quot;$MYPORT&quot; == &quot;3306&quot;];then
  /etc/rc.d/init.d/heartbeat start
  if [ &quot;$HAPORT&quot; == &quot;694&quot; ];then
  echo &quot;$DB1IPmysql and ha all running......&quot;
  else
  echo &quot;$DB1IPmysql is running,ha is down,please restart ha&quot; > /var/log/mysql_ha.log
  mail -s &quot;mysql and ha warning!server: $DB1IP ha is down&quot; hamgua@gmail.com < /var/log/mysql_ha.log
  fi
  else
  echo &quot;$DB1IPmysql and ha all down,let (DB2IP) to take over mysql,please restart mysql&quot; > /var/log/mysql_ha.log
  mail -s &quot;mysql and ha warning!server: $DB1IP mysql and ha all down&quot; hamgua@gmail.com < /var/log/mysql_ha.log
  fi
  fi
  fi
  sleep 10
  done

页: [1]
查看完整版本: 监控mysql跟heartbeat的脚本