mysql cluster 管理 脚本
时间:2007-06-21 来源:oychw
管理节点的脚本: mgmd_keepalive.sh
1, ps afx | grep -w ndb_mgmd | grep -v grep &> /dev/null 中加-w是为了避免把mgmd_keepalive.sh 当作管理进程
2, $? 只针对上一个语句有效.
#!/bin/bash
#
# mgmd_keepalive.sh
#
echo "**********************************************************************" >> /var/log/mgmd-restart-log
echo "Check date: `date`" >> /var/log/mgmd-restart-log
ps afx | grep -w ndb_mgmd | grep -v grep &> /dev/null
if [ $? == 0 ] ; then
echo "mgmd is ok ">> /var/log/mgmd-restart-log
else
# NDBD is dead
echo "ERROR !----------------NDBD is dead!------------------" >>/var/log/mgmd-restart-log
/usr/local/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
wall "mgmd_keepalive.sh restarted mgmd">>/var/log/mgmd-restart-log
echo -n "mgmd_keepalive.sh restarted mgmd:" >> /var/log/mgmd-restart-log
fi
exit 0
数据节点的启动脚本:
[root@ls-db-10 meil]# vi ndbd_keepalive.sh
#!/bin/bash
#
# ndbd_keepalive.sh
#
# Checks that ndbd, the storage daemon for MySQL Cluster,
# is running. If it is not, start it with -n (nostart)
# to allow administrator to start it from within the
# management client
echo "**********************************************************************" >> /var/log/ndbd-restart-log
echo "Check date: `date`" >> /var/log/ndbd-restart-log
ps afx | grep -w ndbd | grep -v grep &> /dev/null
if [ $? == 0 ] ; then
echo "ndbd is ok ">> /var/log/ndbd-restart-log
else
# NDBD is dead
echo "ERROR !----------------NDBD is dead!------------------" >>/var/log/ndbd-restart-log
/usr/local/mysql/bin/ndbd -n
wall "ndbd_keepalive.sh restarted ndbd">>/var/log/ndbd-restart-log
echo -n "ndbd_keepalive.sh restarted ndbd:" >> /var/log/ndbd-restart-log
fi
exit 0