使用 JvisualVM 监控 spark executor

使用 JvisualVM,需要先配置 java 的启动参数 jmx 

正常情况下,如下配置

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=<ip>
-Dcom.sun.management.jmxremote.port=<port>

  然后如下连接即可

但在 spark 中,不能指定具体的 ip 和 port,于是需要如下配置(相关参数 spark.executor.extraJavaOptions)

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=0

  然后找到具体的 container,使用如下命令找到运行的线程,和 pid

ps axu  | grep container_1549968021090_0088_01_000010

  然后通过 pid 找到对应的端口,

sudo netstat -antp | grep 9697
tcp        0      0 ::ffff:10.6.32.218:35735    :::*                        LISTEN      9697/java
tcp        0      0 :::39045                    :::*                        LISTEN      9697/java
tcp        0      0 :::44425                    :::*                        LISTEN      9697/java
tcp        0      0 ::ffff:10.6.32.218:43998    ::ffff:10.6.37.16:16020     ESTABLISHED 9697/java
tcp        0      0 ::ffff:10.6.32.218:48620    ::ffff:10.6.45.22:2181      ESTABLISHED 9697/java
tcp        0      0 ::ffff:10.6.32.218:40082    ::ffff:10.6.33.75:2181      ESTABLISHED 9697/java
tcp        0      0 ::ffff:10.6.32.218:54078    ::ffff:10.6.33.106:16020    ESTABLISHED 9697/java
tcp        0      0 ::ffff:10.6.32.218:54342    ::ffff:10.6.40.161:45389    ESTABLISHED 9697/java
tcp        0      0 ::ffff:10.6.32.218:34058    ::ffff:10.6.40.161:32967    ESTABLISHED 9697/java

  结果中看,疑似为39045或44425,稍微尝试一下即可连上对应的 spark executor

原文地址:https://www.cnblogs.com/keepthinking/p/10380786.html