1: 首先把JDK Linux版本上传到服务器上.
2: 使用命令 jstack PID 命令打印出CPU占用过高进程的线程栈.
3: 使用top -H -p PID 命令查看对应进程是哪个线程占用CPU过高. 比如:
top - 17:23:50 up 12 days, 1:44, 8 users, load average: 4.85, 3.56, 3.76
Tasks: 556 total, 1 running, 555 sleeping, 0 stopped, 0 zombie
Cpu(s): 7.4%us, 4.4%sy, 0.4%ni, 71.6%id, 15.5%wa, 0.0%hi, 0.6%si, 0.0%st
Mem: 32072M total, 31972M used, 100M free, 265M buffers
Swap: 2047M total, 81M used, 1965M free, 23734M cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17363 webserve 20 0 4475m 2.9g 10m R 54 9.4 163:29.84 java
16452 webserve 20 0 4475m 2.9g 10m S 6 9.4 6:03.00 java
11283 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.35 java
11284 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.41 java
11285 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:20.89 java
11288 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.18 java
11291 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.04 java
11280 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:20.66 java
11281 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.41 java
11282 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.26 java
11286 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.36 java
11287 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.43 java
11289 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.80 java
11290 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:22.13 java
11292 webserve 20 0 4475m 2.9g 10m S 2 9.4 7:21.35 java
11293 webserve 20 0 4475m 2.9g 10m S 2 9.4 24:29.70 java
18727 webserve 20 0 4475m 2.9g 10m S 1 9.4 3:08.50 java
18812 webserve 20 0 4475m 2.9g 10m S 1 9.4 3:05.80 java
18829 webserve 20 0 4475m 2.9g 10m S 1 9.4 3:03.32 java
19888 webserve 20 0 4475m 2.9g 10m S 1 9.4 3:04.66 java
比如上面信息就可以看到 17363 线程CPU使用较高, 把这个值转换为 16 进制, 然后在第2步打印的
线程栈中进行搜索, 就可以知道这个线程栈是做什么的了.
1 top
得到最高的pid
2 查看pid子进程
top -H -p PID
3 查看子进程的详情
./jstack -F pid