Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to troubleshoot Java problems in linux

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to troubleshoot Java problems in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux command class

Tail

The most commonly used tail-f

Grep

Awk

1 basic command

2 matching

3 built-in variables

NR:NR indicates the number of data read according to the record delimiter after execution from awk. The default record delimiter is the newline character, so the default is the number of rows of data read. NR can be understood as the abbreviation of Number of Record.

FNR: when awk processes multiple input files, after processing the first file, NR does not start at 1, but continues to accumulate, so there is FNR. Every time a new file is processed, FNR starts counting from 1, and FNR can be understood as File Number of Record.

NF: NF indicates the number of fields in which the current record is divided, and NF can be understood as Number of Field.

Find

Pgm

Batch query logs for which vm-shopbase meets the criteria

Tsar

Tsar is our company's own collection tool. It is easy to persist the data collected by history on disk, so we quickly query the historical system data. Of course, real-time applications can also be queried. It is installed on most machines.

Top

In addition to looking at some basic information about top, all that is left is to cooperate to query various questions about vm.

After getting the thread from decimal to hexadecimal, jstack goes to catch what the thread is doing.

Other

Troubleshooting sharp weapon

Btrace

The first thing to say is btrace. It's really a production environment & a pre-sent troubleshooting problem killer. I won't say anything about the profile. Go straight to the code dry

1. Check who currently calls the add method of ArrayList, and print only the call stack of threads with size greater than 500 for the current ArrayList.

2. Monitor the value returned when the current service method is called and the requested parameters

Note:

After observation, the release output of 1.3.9 is unstable, and it takes several more triggers to see the correct result.

The range of regular expressions matching trace classes must be controlled, otherwise it is very likely that running full of CPU will cause the application to get stuck.

Because of the principle of bytecode injection, if you want the application to return to normal, you need to restart the application.

Greys

Name a few great features (some of which overlap with btrace):

Sc-df xxx: outputs the details of the current class, including source location and classloader structure

Trace class method: I really like this feature! JProfiler could have seen this feature a long time ago. Print out the time-consuming situation of the current method call, subdivided into each method.

JavOSize

Just say one function.

Classes: change the content of the class by modifying the bytecode, effective immediately. So you can quickly log somewhere to see the output, but the disadvantage is that the code is too intrusive. But if you know what you're doing, it's a good thing.

Other functions Greys and btrace can easily do, not to mention.

JProfiler

In the past, many problems had to be judged by JProfiler, but now Greys and btrace can basically solve them. In addition, the problem is basically the production environment (network isolation), so basically do not use it, but still need to mark it.

Mass murderer

EclipseMAT

Can be used as a plug-in for eclipse, can also be opened as a separate program.

Java three axes. Oh, no, seven.

Jps

I only use one command:

Jstack

Common usage:

Native+java stack:

Jinfo

You can see the parameters of the system startup, as follows

Jmap

Two uses

1. Check the heap

2.dump

Or

3. Who's taking over the pile? Together with zprofiler and btrace, troubleshooting problems is like adding power to a tiger.

Jstat

There are many jstat parameters, but one is enough.

Jdb

Today, jdb is also often used.

Jdb can be used to pre-send debug, assuming that your pre-sent java_home is / opt/taobao/java/, remote debug port is 8000. that

Sudo-u admin / opt/taobao/java/bin/jdb-attach 8000.

The above indicates that jdb starts successfully. Breakpoints can be set later for debugging.

CHLSDB

CHLSDB feels that in many cases you can see something more interesting, so I won't elaborate on it. It is said that tools such as jstack and jmap are based on it.

Plugin of intellij idea

Key promoter

You can't remember the shortcut keys once, but you can remember them a few more times, can't you?

Maven helper

A good helper to analyze maven dependency.

VM options

1. From which file is your class loaded?

2. The application failed to output the dump file.

Jar package conflict

Isn't it too much to write a separate headline for this? Everyone has dealt with this annoying case more or less. I can't handle you if I don't believe in so many plans?

Hit out all the dependencies

Type only the dependencies of the specified groupId and artifactId

Vm startup script is added. The details of the loading class can be seen in the tomcat startup script

Vm startup script is added. The details of the loading class can be seen in the tomcat startup script

Greys's sc command can also clearly see where the current class is loaded.

Other

Dmesg

If you find that your java process has disappeared quietly, leaving almost no clues, then dmesg is likely to have what you want.

Find the keyword oom_killer. The results found are similar to the following:

The above shows that the corresponding java process is killed by the OOM Killer of the system, with a score of 854. 5.

Explain OOM killer (Out-Of-Memory killer), which monitors the memory resource consumption of the machine. When the machine runs out of memory, the mechanism scans all processes (calculated according to certain rules, memory usage, time, etc.), picks out the process with the highest score, and then kills it to protect the machine.

Dmesg log time conversion formula:

Log actual time = 1970-01-01 Greenwich mean + (seconds in current time-seconds since the system started + log time printed by dmesg) seconds:

The above is all the contents of the article "how to troubleshoot Java problems in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report