程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> mysql 集群自動監控腳本

mysql 集群自動監控腳本

編輯:關於MYSQL數據庫

這兩個簡單的腳本是用來檢測管理節點和數據節點掛掉的時候能被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 '+%Y-%m-%d %H:%M:%S'`" | 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 '+%Y-%m-%d %H:%M:%S'`" | 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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved