#!/bin/bash # # netconsole This loads the netconsole module with the configured parameters. # # chkconfig:123456 40 60 # description: keephdfsworker source /etc/profile PRO_NAME=keephdfsworker INS_DIR={{ deploy_dir }} #版本 VERSION={{ hadoop_version }} case $1 in start) worker=`ps -ef | grep dae-hdfsworker.sh | grep -v grep | wc -l` if [ $worker -lt 1 ];then nohup $INS_DIR/$VERSION/sbin/dae-hdfsworker.sh > /dev/null 2>&1 & fi ;; stop) HAS_KEEP_SHELL=`ps -ef | grep dae-hdfsworker.sh | grep -v grep | awk '{print $2}'` if [ $HAS_KEEP_SHELL ];then echo "守护进程PID:$HAS_KEEP_SHELL" kill -9 $HAS_KEEP_SHELL fi sh $INS_DIR/$VERSION/sbin/hadoop-daemon.sh stop datanode > /dev/null ;; status) num=`ps -ef | grep DataNode | grep -v grep | wc -l` if [ "$num" -eq "1" ];then echo "DataNode进程已启动" else echo "DataNode进程未启动" fi ;; * ) echo "use keephdfsworker [start|stop|status]" ;; esac