Linux troubleshooting tool Summary

A, Linux troubleshooting command

uptime

top

free

 

 

vmstat

iostat

ifstat

geektime column "linux actual performance optimization," notes

Two, Sun JDK comes with tools

1.jps (VM process status tool)

[peng @ manjaro from java] $ jps - l in
 5524 SynAddRunnable
 5800 suntoolsjpsJps
[peng @ manjaro ~] $ jps - l in
 10872 suntoolsjpsJps
[peng@manjaro ~]$ jps -v
10898 Jps -Denv.class.path=.:/opt/jdk1.8.0_212lib:/opt/jdk1.8.0_212/jre/lib -Dapplication.home=/opt/jdk1.8.0_212 -Xms8m

2.jstat (VM statistics tool)

For example, the query virtual machine operating status information every 1000ms, a total of 5 times

[peng manjaro @ ~] $ jstat -gc 5524  1000  5
 S0C S1C S0U S1U EC EU OC OR TM MU SCCC CCSU YGC YGCT FGC GCTF GCT   
5120.0 5120.0  0.0   352.0  31744.0  21905.2   84992.0      8.0     4864.0 2467.5 512.0  264.6       1    0.001   0      0.000    0.001
5120.0 5120.0  0.0   352.0  31744.0  21905.2   84992.0      8.0     4864.0 2467.5 512.0  264.6       1    0.001   0      0.000    0.001
5120.0 5120.0  0.0   352.0  31744.0  21905.2   84992.0      8.0     4864.0 2467.5 512.0  264.6       1    0.001   0      0.000    0.001
5120.0 5120.0  0.0   352.0  31744.0  21905.2   84992.0      8.0     4864.0 2467.5 512.0  264.6       1    0.001   0      0.000    0.001
5120.0 5120.0  0.0   352.0  31744.0  21905.2   84992.0      8.0     4864.0 2467.5 512.0  264.6       1    0.001   0      0.000    0.001

3.jmap (Java memory mapping tool)

Students can heap dump snapshot (commonly referred to as heapdump or dump file). Get Java heap dump snapshots in the following ways:

① (automatically generated) using -XX: + HeapDumpOnOutOfMemoryError parameters, so that the virtual machine after OOM automatically generated dump file

② (manual generation) using -XX: + HeapDumpOnCtrlBreak parameters, in Windows you can use Ctrl + Break key to make the virtual machine to generate dump files,

By under Linux the kill -3 exit signal "scare" about the virtual machine, but also to get the dump file command sending process.

③ use jmap command

4.jhat (Virtual Machine heap dump snapshot analysis tool)

There are already better tools, such as MAT, jhat has officially been removed in JDK9

5.jinfo (Java configuration tool)

Real-time view of the current jvm Which parameter, and can modify parameters without stopping the machine.

6.jstack (java stack trace tool)

7. alternatives jcmd

Official website: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html

jcmd jdk7 is introduced, it can replace jstack.

 

jstat

The more commonly used tool, you can view the details of the GC, such as memory usage area of ​​eden, from, to, old and so on.

Third, the visual analysis tool

JConsole

Java Visual VM

Java Visual VM (JVisualVM) from JDK6u23 begin until JDK8 as part of Oracle JDK, JDK9 and later as a separate project.

Fourth, other tools

Btrace

Official website: https://github.com/btraceio/btrace 

Arthas

Ali heavy open-source tool for online analysis and diagnosis, the official website address: https://alibaba.github.io/arthas/

MAT(Memory Analyzer Tool)

Official website: https://www.eclipse.org/mat/downloads.php

Mainly used to diagnose memory leaks and high memory usage problems.

Jprofiler

Official website: https://www.ej-technologies.com/products/jprofiler/overview.html

JProfiler Java software is used to analyze performance bottlenecks and can accurately locate the class or method effectively solve the performance problems of mainstream tool, it usually needs and performance testing tools (such as LoadRunner) with the use, since it is often only when the system is under pressure to reflect the state a performance issue. Jprofiler for a fee.

Fourth, the common troubleshooting thinking

1.CPU Biao high

Ideas: First, find the Java process high CPU Biao, because you have multiple server JVM process. Then find the "question thread" that process, and finally found the problem code based on thread stack information. Finally, the code investigation.

Specific steps:

  1. Through the top order to find the most CPU consuming process, and to remember the process ID .
  2. By again top -Hp [process ID] we found the highest consumption of CPU thread ID, and remember the thread ID .
  3. JDK provided by jstack tool dump thread stack information to the specified file. Specific command: jstack -l [process ID]> jstack.log.
  4. Just because the thread ID is decimal, and stack information in the thread ID is hexadecimal, so we need to be converted to decimal hexadecimal, and look at the stack with the thread ID. Use printf "% x \ n" [decimal number], can convert decimal to hexadecimal.
  5. Find the corresponding thread stack from the stack information in hexadecimal numbers just by conversion. It can be discerned from the stack.

Visualization tool to analyze dump files, MAT, Jprofile, jvisualvm etc. These tools can analyze jmap dump down the file to see which object to use more memory, usually able to identify the problem.

Common scenarios of problems:

① generally a business cycle is not dead exports, this situation can be repaired according to the service.

② there C2 compiler will compile grab CPU time, what is C2 compiler do? After a certain period of Java code is more than 10,000 times the number of executions (default), this section will explain the changed code execution from compiler implementation, which is compiled into machine code to improve speed. And this C2 compiler does just that. How to solve it? After the on-line project, you can start by preheating pressure measurement tool, so users such as real time access, C2 compiler will not interfere with the application. If GC thread lead, then most likely Full GC, it is necessary to optimize the GC.

2. Memory troubleshooting

One is a memory leak, one is undisclosed.

+ HeapDumpOnOutOfMemoryError parameter, which is the output action dump file when the program out of memory: memory overflow can be added by -XX. With the dump file can be analyzed through the dump analysis tools, such as the commonly used MAT, Jprofile, jvisualvm and other tools can be analyzed, these tools are able to see in the end is where the overflow, where a large number of objects created and so forth.

 

Reference: the Java Virtual Machine online troubleshooting of two basic operations, you know?

 

 

 

 

to sum up:

 

GC

①gc situation: jmap, jcmd (oracle official recommended jcmd instead of jmap, because jcmd really can replace many functions .jmap jmap can print distribution information objects, you can dump file, note that when jmap and jcmd dump file will trigger the FGC, Note that when using the scene.)

② there is a commonly used tool is jstat, the tool can view the details of the GC, such as memory usage area of ​​eden, from, to, old and so on.

③ There is a tool jinfo, the tool can view the current jvm Which parameter, and can modify parameters without stopping the machine.

 

Visualization tool to analyze the dump file

①MAT

②Jprofile

③jvisualvm 

 

Guess you like

Origin www.cnblogs.com/rouqinglangzi/p/11911040.html