1. Business Log Related
If the system is abnormal or the business is abnormal, the first thing to think about is to view the business log
To view the log tool:
Less or more
Grep
tail-f filename View the latest content in real time
PS: Avoid vim directly open large log file, because it will be loaded directly into the memory of the
2. Database related
Java application A lot of bottlenecks in the database, a SQL is not written to cause slow query, it may bring the application of fatal harm.
If a Could not get JDBC Connection is present, the interface responds slowly, the thread is full, etc.
need to log on to the online library,
View database connection: Show processlist, check the current database connection, indeed due to slow query, need to manually kill
3. JVM-related
Java Virtual machine-related problems are generally many of the following problems: GC time is too long, OOM, deadlock, thread block, the number of threads soared and so on. In general, the following tools are available to locate the problem.
JPS command
Jinfo command
Jstat command
Jstack command
Jmap command
3.1 Oom Problem
In the event of an oom problem, the General Service will crash and the business log will be outofmemoryerror. Oom is generally a memory leak, need to look at the time of the Oom JVM heap snapshot, if configured with-xx:+heapdumponoutofmemoryerror, in the event of Oom will be in-xx:heapdumppath heap of dump files, Combined with mat, you can analyze the dump file to find out why oom occurred. About mat use is not detailed, Google on a bunch (http://inter12.iteye.com/blog/1407492).
Ps.
1, the server memory is generally large, so to ensure that the server disk space is larger than the memory size
2, another manual dump heap snapshot, you can use the command jmap-dump:format=b,file=file_name pid or kill-3 pid
3.2 Dead Lock
The cause of the deadlock is two or more threads waiting for resources, the phenomenon is usually the thread hung live, more serious will appear the number of threads skyrocket, the system appears API alive alarm and so on. The best way to look at deadlocks is to analyze the line stacks at that time.
Specific case can refer to the example in the Jstack command
The command to use:
Jps-v
Jstack-l PID
3.3 Thread block, number of threads skyrocket
Jstack-l PID |wc-l
Jstack-l pid |grep "BLOCKED" |wc-l
Jstack-l pid |grep "Waiting on condition" |wc-l
The thread block problem is usually waiting for Io, waiting for the network, waiting for the monitor lock, and so on, may cause the request to time out, causing the number of threads to skyrocket resulting in system 502.
If this problem occurs, the main concern is jstack out of the blocked, waiting on thecondition, waiting on monitor entry and other status information.
If a large number of threads are in "Waiting for Monitor entry":
A global lock may be blocking a large number of threads.
If the thread dump file printed in a short time reflects, over time, the waiting for monitor entry threads more and more, without decreasing the trend that could meanSome threads spend too much time in the critical section, so that more and more new threads are unable to enter the critical section .。
If a large number of threads are in "waiting on condition":Maybe they're running again. Acquiring third-party resources, delayed access to response, causing a large number of threads to enter the wait state. So if you find that there are a lot of threads in wait on condition, looking from the thread stack, waiting for the network to read and write, which could be a symptom of a network bottleneckBecause the network blocking causes the thread to fail to execute. 3.3 gc time is too long
Todo
Put an article first occupy pit: http://www.oracle.com/technetwork/cn/articles/java/g1gc-1984535-zhs.html
4, Server Problem 4.1 CPU
Top Command (Refer to https://linux.cn/article-2352-1.html)
Focus on CPU load and CPU-intensive processes
Since the server is now a virtual machine, also focus on St (ST's full name is steal time, is allocated to the task running on other virtual machines of the actual CPU times)
Common Interactive Commands:
h Help, very useful
R: Reverse Sort
x: Highlighting the sorted character (column)
Y Highlight the running process (rampage)
Shift+> or shift+<: Toggle Sort Field
D or S: Sets the refresh interval for the display
F: Field management settings display fields
K:kill process
4.2 Memory
Free command:
Free-m-C10-S1
-M: shown in MB, others have-k-g-B
-S: How many seconds to continuously observe memory usage
-C: Observe how many times
Vmstat command: (http://man.linuxde.net/vmstat)
Vmstat 1 10
1 means every 1s output, 10 means output 10 times
Two parameters to focus on
R: The number of processes running in the queue, this value can also determine whether to increase the CPU. (longer than 1)
B: The number of processes waiting for IO.
4.3 IO
Iostat Command (http://www.orczhou.com/index.php/2010/03/iostat-detail/)
Iostat-m 1 10
- -M: Some columns using block are forced to use MB
- 1 10: Data display refreshed every 1 seconds, total display 10 times
4.4 Network
netstat command (http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316661.html)
Netstat-antp
-A (All) displays all options and does not show listen related by default
-T (TCP) displays only TCP-related options
-U (UDP) displays only UDP-related options
-N refuses to display aliases, showing all numbers converted to numbers.
-l list only service status in Listen (listening)
-P Displays the program name that establishes the associated link
Displays the number of TCP individual states:
Netstat-ant |awk ' {print $6} ' |sort|uniq-c
View the IP addresses that connect to a service port
Netstat-nat | grep "10.32.45.35:8924" |awk ' {print $} ' |awk-f: ' {print $4} ' |sort|uniq-c|sort-nr|head-10
Troubleshoot Java on-line service issues