In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "analyzing the train of thought of problem troubleshooting under the Java production environment". In the daily operation, I believe that many people have doubts in analyzing the problem troubleshooting train of thought under the Java production environment. The editor has consulted all kinds of materials and sorted out the simple and useful operation methods. I hope it will be helpful to answer the doubts of "analyzing the problem troubleshooting train of thought under the Java production environment". Next, please follow the editor to study!
Troubleshooting in Java production environment
In a production environment, we cannot immediately check the current running status and get error messages through breakpoint debugging, new log, and visualization tools. At this time, with the help of Java's own command-line tools and related dump analysis tools and some tips, we can greatly improve our efficiency in troubleshooting problems.
Operation parameters
Here are some commonly used and very effective commands and parameters to view information about the runtime Java program to help you understand the running status of the program.
View JVM parameters
Jps-l looks at all running Java programs, displays the startup class name, and gets the PID.
4706 org.apache.catalina.startup.Bootstrap
5023 sun.tools.jps.Jps
Jinfo-flags PID to view runtime process parameters and JVM parameters
Attaching to process ID 28987, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.171-b11
Non-default VM flags:-XX:CICompilerCount=3-XX:InitialHeapSize=132120576-XX:MaxHeapSize=2092957696-XX:MaxNewSize=697303040-XX:MinHeapDeltaBytes=524288-XX:NewSize=44040192-XX:OldSize=88080384-XX:+UseCompressedClassPointers-XX:+UseCompressedOops-XX:+UseParallelGC
Command line:-Dspring.config.location=application.properties-Dspring.profiles.active=staging
Java-XX:+PrintFlagsFinal-version view the default JVM parameters of the current virtual machine
View instant GC status
Jstat-gc PID 1000 10 checks the gc information once per second for a total of 10 times, and outputs more parameters.
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
512.0 512.0 15.3 0.0 4416.0 1055.2 11372.0 7572.5 14720.0 14322.5 1664.0 1522.8 40 0.137 8 0.039 0.176
During this period, you may encounter a prompt sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 24.181-b01. The problem with Target VM is 25.171-b11 is that multiple versions are installed. Use which and ls-l to navigate to the same version of Java as the currently executed Java program.
Error troubleshooting
Memory problem
Memory leak caused OOM? Unusually high memory footprint? This is a common problem in the production environment. Java provides dump files for us to record what happened in memory, and we need some tools to get valuable information from it.
Export Dump fil
Print the dump file-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=./ with these parameters to the Java program in advance
Use jmap:jmap-dump:format=b,file=heap.hprof PID for running programs
Analyze Dump files
If the Dump file is not too large, it can be sent to the designated channel for analysis. The file is relatively large, and you want to make a more systematic analysis. It is recommended to use MAT analysis. There are several common ways to view it:
[Leak Suspects] on the home page can speculate what the problem is
Click [Create a histogram from an arbitrary set of objects] to find the number of all objects.
Right-click an object [Merge Shortest Paths to GC Roots]-> [exclude all phantom/weak/soft etc. References] to find out which GC ROOT references a large number of objects.
Thread problem
Does the task not quit for a long time? the CPU load is too high? Probably because of deadloops or deadlocks, some threads execute uninterrupted all the time, but not reporting errors is the most annoying, so there is no error message in the log and cannot be analyzed with dump files because it has nothing to do with memory. At this point, we need to use thread analysis tools to help us.
Export jstack fil
Use the jstack PID > file. If it fails, add the-F parameter. If it still fails, use the user you used to start the Java program to execute jstack. The following is part of the output format of jstack:
Hexadecimal of thread name PID
"http-nio-8080-Acceptor-0" # 17 daemon prio=5 os_prio=0 tid=0x00007fac2c4bd000 nid=0x29f4 runnable [0x00007fac192f6000]
Java.lang.Thread.State: RUNNABLE (the worker thread of tomcat is running and has NEW/RUNNABLE/BLOCKED/WAITING/TIMED_WATING/TERMINATED status)
At sun.nio.ch.ServerSocketChannelImpl.accept0 (Native Method)
At sun.nio.ch.ServerSocketChannelImpl.accept (ServerSocketChannelImpl.java:422)
At sun.nio.ch.ServerSocketChannelImpl.accept (ServerSocketChannelImpl.java:250)
-locked (a java.lang.Object)
At org.apache.tomcat.util.net.NioEndpoint$Acceptor.run (NioEndpoint.java:682)
At java.lang.Thread.run (Thread.java:748)
The output of jstack can see all the threads and their status, and we can see which running threads we created ourselves, which is probably the one that has been executing, and the thread name is particularly important at this time, so it is recommended to specify a meaningful thread name when creating a new thread. Of course, it is also very convenient to find it through PID.
At this point, the study of "analyzing the train of thought of troubleshooting in the Java production environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.