Detection Script MYSQL cluster management nodes and data nodes

These two simple script that is used to detect nodes and data management node cluster MYSQL hang time can be pulled into it.
Since MYSQL cluster node can only broken kicked out, if the network take away or otherwise. He can not pull back self-sufficiency.

1, the management node script

# / bin / bash!
#
# Short Managment the Keep Alive File.
#
# The Created by david Yeung 2007-12-20
#
# Filename:. Mgmd_check_online.sh
#
# determinate model types within the To mgmd Process IS running or not .
#
PS AFX | grep -w ndb_mgmd | grep -v grep 1> & / dev / null

IF [$ == 0?]
the then
  echo "------- ------- MGMD IS the ok! ------ ">> / var / log / mgmd the online.log-Check-!
the else

  # Dead NDBD IS.
  echo" the Check DATE: DATE ` '+% Y-M-% D%% H:% M :% S'` "| tee -a / var / log / mgmd-check-online.
  echo "! ---------- ------- MGMD IS Dead!" | TEE -a /var/log/mgmd-check-online.log
  . # the Run at The Managment the Node
  / usr / local / MySQL / ndb_mgmd -f /etc/config.ini
  echo "------- ----------- MGMD NODE the OK!!" | TEE -a / var / log / mgmd- the online.log-Check
Fi
Exit 0



is then added to the crontab
[the root @localhost mysql_test] # the crontab -l
* / * * * *. 1 /home/mysql_test/mgmd_check_online.sh
spread additional management node, and then added CRONTAB
[the root @ localhost mysql_test] mgmd_check_online.sh [email protected] SCP #: ~
of The Host Authenticity of '192.168.0.232 (192.168.0.232)' Not CAN BE ESTABLISHED.
the RSA Key Fingerprint IS 47: 39: 89: A7: F7:. 1A : fc: 0a: 6f: 7a : 4b: b5: 91: 28: 48: e8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.232' (RSA) to the list of known hosts.
[email protected]'s password:
mgmd_check_online.sh                          100%  680     0.7KB/s   00:00   

日志内容:
!-------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



传到我的236
[root@localhost mysql_test]# scp ndbd_check_online.sh [email protected]:~
[email protected]'s password:
ndbd_check_online.sh                          100%  614     0.6KB/s   00:00 

This article comes from " God, let there or be square! " Blog, reproduced please contact the author!

Reproduced in: https: //my.oschina.net/u/585111/blog/219483

Guess you like

Origin blog.csdn.net/weixin_34234823/article/details/92008322