为hadoop开启远程调试,加在bin/hadoop里。
# Turn on debug mode if neccesary
debug_file="$bin/hadoop.debug"
is_debug_enabled()
{
if [ -f $debug_file ]; then
cat $debug_file | grep $1 >/dev/null 2>&1
fi
}
case "$COMMAND" in
namenode)
DEBUG_PORT=11000
;;
datanode)
DEBUG_PORT=11001
;;
jobtracker)
DEBUG_PORT=11002
;;
tasktracker)
DEBUG_PORT=11003
;;
secondarynamenode)
DEBUG_PORT=11004
;;
esac
if is_debug_enabled $COMMAND && [ ! -z $DEBUG_PORT ]; then
echo "debug for $COMMAND is enabled, port is $DEBUG_PORT"
HADOOP_OPTS="$HADOOP_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,suspend=y,server=y"
fi