When a record close Hadoop no namenode to stop abnormal

When a record close Hadoop no namenode to stop abnormal

Ran on its own virtual machine environment hadoop cluster has been running normally, when not directly suspended virtual machine, you need to make some adjustments today, but suddenly found that clusters can not be closed properly. Then resorted to Baidu Dafa ~:

As we all know, shut down the cluster command stop-dfs.sh, and stop-yarn.shthen I finished the goose perform specific situation is this:

[simon@master ~]# stop-dfs.sh 
Stopping namenodes on [master]
master: no namenode to stop
slave2: no datanode to stop
slave1: no datanode to stop
...

Ah ah ah ... this is what some ... I do not know ...

It starts normally but can not stop? kiding me?

Execute jpscommands, found namenode, datanode and other processes are running normally. Satisfied, bored!

After the final reference bigwigs blog, start reading hadoop-daemon.sh script file, and then find out the cause of the problem issues.

1 is first determined, an error location code appears:
 if [ -f $pid ]; then
      TARGET_PID=`cat $pid`
      if kill -0 $TARGET_PID > /dev/null 2>&1; then
        echo stopping $command
        kill $TARGET_PID
        sleep $HADOOP_STOP_TIMEOUT
        if kill -0 $TARGET_PID > /dev/null 2>&1; then
          echo "$command did not stop gracefully after $HADOOP_STOP_TIMEOUT seconds: killing with kill -9"
          kill -9 $TARGET_PID
        fi
      else
        echo no $command to stop
      fi
      rm -f $pid
    else
      echo no $command to stop
    fi

Yes, the error is behind a few lines of code

    ....省略
    else
      echo no $command to stop
    fi

Now for obvious reasons, if no pid file, in time to stop the cluster will be reported out of the error. So what is the pid file it? Why can not find it?

2, through access to information that, such a line of code in the script
#第107行
pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid 
  • Here it can be seen, HADOOP_PID_DIRvariable specifies the directory where pid file hadoop of.

  • Then the pid file is Shane. You can follow the process PID to shut down the process when the Hadoop startup, will process PID number is stored in a file, so the implementation of stop-dfs script.

    Find the HADOOP_PID_DIRdefault path:

    if [ "$HADOOP_PID_DIR" = "" ]; then   #97~99行
      HADOOP_PID_DIR=/tmp
    fi

    ok, understand, pid file storage directory cluster is the system /tmpdirectory, and the file system in this directory will be cleaned regularly. I built up since this cluster has been running, pid file has long been cleared. So we give it another specified directory, you can define your own. I'll set it up /home/tmp/pid.

3. Set to proceed

Since the stopcommand is not available, then we can only manually closed, jpssee your PID namenode \ datanode and other processes, and then kill -9 to kill.

if [ "$HADOOP_PID_DIR" = "" ]; then   #97~99行
  HADOOP_PID_DIR=/home/tmp/pid   # 创建这个文件夹用于存放pid文件
fi

You're done, you can restart the cluster ~

Guess you like

Origin www.cnblogs.com/simon-1024/p/11741469.html