苦于不知道如何通过远程调试跟进spark源码,千方百计的去搜索资源,终于搞会了,现在分享一下远程调试的步骤
1、Master Worker 远程调试
1.1 在spark-env.sh末尾新增2行代码
export SPARK_MASTER_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=10005"
export SPARK_WORKER_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=10006"
1.2 重启master、worker进程
stop-master.sh
start-master.sh
stop-slave.sh
start-slave.sh spark://localhost:7077
1.3 回到idea 添加master worker的远程调试配置
1.4 进入Master源码(spark-2.4.0)的line 1053行加debug断点
启动调试程序
调试成功
Executor远程调试配置类似Master,不过executor需要在程序参数加
config("spark.executor.extraJavaOptions","-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=10002")