Java开发必须掌握的线上问题排查命令

运行日志、异常堆栈、堆使用情况、GC情况、JVM参数情况、线程情况等

给一个系统定位问题的时候,知识、经验是关键,数据是依据,工具是运用知识处理数据的手段。

为了便于我们排查和解决问题,jdk/lib/tools.jar中类库的一层薄包装

jps

显示当前所有java进程pid的命令

jinfo

实时查看和调整虚拟机参数

jstat

显示进程中的类装载、内存、垃圾收集、JIT编译等运行数据

jstat -gc 3331 250 20 :查询进程2764的垃圾收集情况,每250毫秒查询一次,一共查询20次。

jstat -calss:查询类装载、类卸载、总空间以及所消耗的时间

jmap

生成堆转储快照(heapdump)

jmap -heap 3331:查看java 堆(heap)使用情况

jmap -histo 3331:查看堆内存(histogram)中的对象数量及大小

jmap -histo:live 3331:JVM会先触发gc,然后再统计信息

jhat

一般与jmap搭配使用,用来分析jmap生成的堆转储文件

由于有很多可视化工具(Eclipse Memory Analyzer 、IBM HeapAnalyzer)可以替代,所以很少用。不过在没有可视化工具的机器上也是可用的

jmap -dump:format=b,file=heapDump 3331

jstack

jstack 3331:查看线程情况jstack -F 3331:正常输出不被响应时,使用该指令jstack -l 3331:除堆栈外,显示关于锁的附件信息

频繁GC问题或内存溢出问题

一、使用jps查看线程ID

二、使用jstat -gc 3331 250 20 查看gc情况,一般比较关注PERM区的情况,查看GC的增长情况。

三、使用jstat -gccause:额外输出上次GC原因

四、使用jmap -dump:format=b,file=heapDump 3331生成堆转储文件

五、使用jhat或者可视化工具(Eclipse Memory Analyzer 、IBM HeapAnalyzer)分析堆情况。

六、结合代码解决内存溢出或泄露问题。

死锁问题

一、使用jps查看线程ID

二、使用jstack 3331:查看线程情况
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...

你可能感兴趣的:(java)