Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19912243
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类: Mysql/postgreSQL

2007-06-21 08:41:27

管理节点的脚本: 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

阅读(3349) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~