hadoop源码调试跟踪方法
- - 开源软件 - ITeye博客最近经常有问我hadoop源码怎么看的问题,做以下讲解希望有用(hdfs调试为例). 1.在eclipse中建立java工程,然后把hadoop的src包中的内容拷贝到src资源下(仅org的即可). 2.导入hadoop中lib目录下的jar直到代码不再报错. 3.搭建一个hadoop的集群,我的测试环境是1个nn和3的dn.
export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_NAMENODE_OPTS"
#export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_NAMENODE_OPTS"
export HADOOP_NAMENODE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8080,server=y,suspend=y"
-Xdebug 设置为调试启动 -Xrunjdwp 调试方式,后面的都是该方式的参数: transport=dt_socket:表示断点通过socket传输(远程打断点) address=8000:调试用的服务端口,远程被调试的那个nn就是服务 server=y 表示是被调试的服务,如果是n表示调试者 suspend=y 表示是否等待链接调试
<property> <name>mapred.child.java.opts</name> <value>-Xmx1024m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8081</value> </property>
<property> <name>mapred.tasktracker.map.tasks.maximum</name> <value>1</value> </property> <property> <name>mapred.tasktracker.reduce.tasks.maximum</name> <value>1</value> </property>
case "${COMMAND}" in application|applicationattempt|container) CLASS=org.apache.hadoop.yarn.client.cli.ApplicationCLI hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" set -- "${COMMAND}" "$@" ;; classpath) hadoop_finalize echo "${CLASSPATH}" exit ;; daemonlog) CLASS=org.apache.hadoop.log.LogLevel hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; jar) CLASS=org.apache.hadoop.util.RunJar hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; historyserver) daemon="true" echo "DEPRECATED: Use of this command to start the timeline server is deprecated." 1>&2 echo "Instead use the timelineserver command for it." 1>&2 echo "Starting the History Server anyway..." 1>&2 CLASS='org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer' ;; logs) CLASS=org.apache.hadoop.yarn.client.cli.LogsCLI hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; node) CLASS=org.apache.hadoop.yarn.client.cli.NodeCLI hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; nodemanager) daemon="true" CLASS='org.apache.hadoop.yarn.server.nodemanager.NodeManager' hadoop_debug "Append YARN_NODEMANAGER_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_NODEMANAGER_OPTS}" if [[ -n "${YARN_NODEMANAGER_HEAPSIZE}" ]]; then JAVA_HEAP_MAX="-Xmx${YARN_NODEMANAGER_HEAPSIZE}m" fi ;; proxyserver) daemon="true" CLASS='org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer' hadoop_debug "Append YARN_PROXYSERVER_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_PROXYSERVER_OPTS}" if [[ -n "${YARN_PROXYSERVER_HEAPSIZE}" ]]; then JAVA_HEAP_MAX="-Xmx${YARN_PROXYSERVER_HEAPSIZE}m" fi ;; resourcemanager) daemon="true" CLASS='org.apache.hadoop.yarn.server.resourcemanager.ResourceManager' YARN_OPTS="${YARN_OPTS} ${YARN_RESOURCEMANAGER_OPTS}" hadoop_debug "Append YARN_RESOURCEMANAGER_OPTS onto YARN_OPTS" if [[ -n "${YARN_RESOURCEMANAGER_HEAPSIZE}" ]]; then JAVA_HEAP_MAX="-Xmx${YARN_RESOURCEMANAGER_HEAPSIZE}m" fi ;; rmadmin) CLASS='org.apache.hadoop.yarn.client.cli.RMAdminCLI' hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; timelineserver) daemon="true" CLASS='org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer' hadoop_debug "Append YARN_TIMELINESERVER_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_TIMELINESERVER_OPTS}" if [[ -n "${YARN_TIMELINESERVER_HEAPSIZE}" ]]; then JAVA_HEAP_MAX="-Xmx${YARN_TIMELINESERVER_HEAPSIZE}m" fi ;; sharedcachemanager) daemon="true" CLASS='org.apache.hadoop.yarn.server.sharedcachemanager.SharedCacheManager' YARN_OPTS="$YARN_OPTS $YARN_SHAREDCACHEMANAGER_OPTS" ;; version) CLASS=org.apache.hadoop.util.VersionInfo hadoop_debug "Append YARN_CLIENT_OPTS onto YARN_OPTS" YARN_OPTS="${YARN_OPTS} ${YARN_CLIENT_OPTS}" ;; *) CLASS="${COMMAND}" if ! hadoop_validate_classname "${CLASS}"; then hadoop_exit_with_usage 1 fi ;; esac
YARN_RESOURCEMANAGER_OPTS="$YARN_RESOURCEMANAGER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=22222"