文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>mysql 集群自动监控脚本:监控DATA NODE与MGM NODE

mysql 集群自动监控脚本:监控DATA NODE与MGM NODE

时间:2010-04-09  来源:*梦*

这两个简单的脚本是用来检测管理节点和数据节点挂掉的时候能被MYSQL集群拉进去。
由于MYSQL集群只能把坏掉的节点踢出去,如果网络端掉或者其他情况。他不能自给拉回来。

1、管理节点的脚本

#!/bin/bash

# Short managment keep alive file.
# Created by david yeung 2007-12-20
# Filename: mgmd_check_online.sh.
# To determinate whether mgmd process is running or not.

ps afx | grep -w ndb_mgmd | grep -v grep 1>&/dev/null
if [ $? == 0 ]
then
echo "!-------MGMD is ok-------------!">>/var/log/mgmd-check-online.log
else

# NDBD is dead.
echo "Check date:`date '+%F %T'`" | tee -a /var/log/mgmd-check-online.log
echo "!-------MGMD is dead ----------!" | tee -a /var/log/mgmd-check-online.log
# Run the managment node.
/usr/local/mysql/ndb_mgmd -f /etc/config.ini
echo "!-------MGMD NODE OK-----------!" | tee -a /var/log/mgmd-check-online.log
fi
exit 0

 

然后加入到crontab
[root@localhost TM]# crontab -l
*/1 * * * * /usr/local/scripts/mgmd_check_online.sh

日志内容:
!-------MGMD is ok-------------!
Check date:2007-12-20 16:52:51
!-------MGMD is dead ----------!
!-------MGMD NODE OK-----------!

...


2、数据节点的脚本

#!/bin/bash

# Created by david yeung 2007-12-20.
# Short ndbd node keep alive file.
# Filename:ndbd_check_online.sh.
# To determinate whether ndbd process is running or not.

ps afx | grep -w ndbd | grep -v grep 1>& /dev/null
if [ $? == 0 ]
then
echo "!-------NDBD is ok-------------!" >> /var/log/ndbd-check-online.log
else
# NDBD is dead
echo "!-------NDBD is dead ----------!" | tee -a /var/log/ndbd-check-online.log
echo "Check date:`date '+%F %T'`" | tee -a /var/log/ndbd-check-online.log
echo "!-------RESTART NDBD ----------!" | tee -a /var/log/ndbd-check-online.log
# The real command
/usr/local/mysql/bin/ndbd
echo "!-------NDBD NODE OK-----------!" | tee -a /var/log/ndbd-check-online.log
fi
exit 0

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载