1.根据端口号57638查看对应进程pid/name=1463/java
netstat -apn | grep 57638
tcp 0 0 ::ffff:172.20.5.10:57638 :::* LISTEN 1463/java
tcp 0 0 ::ffff:172.20.5.10:57638 ::ffff:172.20.5.14:59204 ESTABLISHED 1463/java
2. top 查看占用内存最多的几个进程
ps aux | grep applicationName 查看对应applicationName的pid, 第二列表示pid 1463
root 1463 12.5 2.3 5531468 3057636 ? Sl Oct12 315:22
3. top -p pid -H 查看进程pid对应的线程信息,这里每个线程映射对应到linux的一个进程PID
top -p 1463 -H
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1463 root 20 0 5401m 2.9g 39m S 0.0 2.3 0:00.00 java
1464 root 20 0 5401m 2.9g 39m S 0.0 2.3 0:01.69 java
4. 使用jstack查看对应线程的具体信息
jstack pid | grep -A 10 hex(id)
pid进程id, -A 表示 取出对应行后,往后继续显示10行内容,
hex(id) 表示线程PID对应的十六进制数字,全部用小写字母表示,
可以借助计算器 或其他工具进行转换, 用python 转换: python -c "print (hex(1464))"
jstack 1463 | grep -A 10 `python -c "print (hex(1464))"` "main" #1 prio=5 os_prio=0 tid=0x00007f15ac01e800 nid=0x5b8 waiting on condition [0x00007f15b0a37000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000700016ba0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.ThreadPoolExecutor.awaitTermination(ThreadPoolExecutor.java:1465)
at org.apache.spark.rpc.netty.Dispatcher.awaitTermination(Dispatcher.scala:180)
at org.apache.spark.rpc.netty.NettyRpcEnv.awaitTermination(NettyRpcEnv.scala:273)
at org.apache.spark.executor.CoarseGrainedExecutorBackend$$anonfun$run$1.apply$mcV$sp(CoarseGrainedExecutorBackend.scala:231)
at org.apache.spark.deploy.SparkHadoopUtil$$anon$1.run(SparkHadoopUtil.scala:67)
ref: http://blog.csdn.net/jiafu1115/article/details/7355628
http://flysnowxf.iteye.com/blog/1162691
https://www.zhihu.com/question/20238208
http://blog.csdn.net/hanghangaidoudou/article/details/51488249