Java Troubleshooting 排障

Quick Troubleshooting Tips 快速排障 For Linux , OS X

Hung,DeadLocked,Looping Process 掛起,死鎖,迭代

  • 打印Java線程棧
jcmd 找到pid
kill -QUIT pid
jstack [-F] pid 打印全部線程 Dump
  • 偵測死鎖
jconsole 工具 Thread Tab 按鈕 檢測死鎖
jstack -l pid
  • Dump 可以使用診斷工具,參考另外一篇文章
jmap -dump:format=b,file= filename pid (with -F option if pid does not respond)   導出Dump
jhat heap-dump-file  分析Dump
jmap 其它命令  比較有用的
jmap -heap pid
jmap -finalizerinfo pid
  • jdb Java Debug工具 注意須要權限 若是沒使用過,能夠先使用help瞭解一下
$:sudo jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=pid
>:help

Troubleshoot System Crashes 系統崩潰排障

系統崩潰,異常終止,Java HotSpot VM,System Library,Java SE Library、API,Application Native Code,OS。。。;html

定位 Locate

錯誤日誌
[Error Log](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/felog.html#fatal_error_log_vm "Error Log")

確認 Determine Where the Crash Occurred

異常日誌格式java

#  SIGSEGV (0xb) at pc=0x417789d7, pid=21139, tid=1024
      |      |           |             |         +--- thread id
      |      |           |             +------------- process id
      |      |           +--------------------------- program counter
      |      |                                        (instruction pointer)
      |      +--------------------------------------- signal number
      +---------------------------------------------- signal name
# Problematic frame:
# C  [libNativeSEGV.so+0x9d7]
  |              +-- Same as pc, but represented as library name and offset.
  |                  For position-independent libraries (JVM and most shared
  |                  libraries), it is possible to inspect the instructions
  |                  that caused the crash without a debugger or core file
  |                  by using a disassembler to dump instructions near the
  |                  offset.
  +----------------- Frame type
Frame Type Description
C Native C frame
j Interpreted Java frame
V VM frame
v VM-generated stub frame
J Other frame types, including compiled Java frames
Native Code
Compiled Code
HotSpot Compiler Thread
	線程名CompilerThread
VM Thread
	線程名VMThread
Stack Overflow
	異常類型EXCEPTION_STACK_OVERFLOW
	_thread_in_native

分析

解決

報告

參考

相關文章
相關標籤/搜索