kill-name-node 830 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # HDP configures the NameNode JVM process to call this script on
  3. # OutOfMemoryError. This will find and kill the NameNode process. It's
  4. # potentially dangerous to keep running the NameNode after an OutOfMemoryError.
  5. # There is a risk that a file system change could be applied to the in-memory
  6. # metadata but not made persistent to the edit log. HDFS contains legacy code
  7. # that catches OutOfMemoryError, so we need to use this script to kill it
  8. # externally.
  9. NNPID=$("$JAVA_HOME"/bin/jps | grep -E '^[0-9]+[ ]+NameNode$' | awk '{print $1}')
  10. if [ $? -gt 0 ]; then
  11. echo "ERROR: Command failed while looking for NameNode PID."
  12. exit 1
  13. fi
  14. if [ -z "$NNPID" ];
  15. then
  16. echo "ERROR: Could not find a NameNode PID."
  17. exit 1
  18. fi
  19. kill -9 "$NNPID"
  20. if [ $? -gt 0 ]; then
  21. echo "ERROR: Kill command failed."
  22. exit 1
  23. fi