今天登陆同事的一台gateway 开始以为hive环境登陆不了了,仔细一看看了下是因为机器很卡,我每次等几秒没登陆就ctrl+c了,看了下是有个java进程cpu:340.4% mem:14.6%
一般解决方法是通过top命令找出消耗资源高的线程id,利用strace命令查看该线程所有系统调用
1. 通过top命令找到可疑进程PID
top 一下
可以看出java进程CPU利用率一直保持100%,稳居不下,找到PID 24138
2. 找出消耗资源最高的线程
top -H -p 29580 可以不用第一步,直接执行命令 top -H ,就可以查看到消耗资源最高的线程
top - 20:42:01 up 633 days, 9:30, 9 users, load average: 6.75, 8.32, 15.86 Tasks: 28 total, 2 running, 26 sleeping, 0 stopped, 0 zombie Cpu(s): 42.4%us, 4.3%sy, 0.0%ni, 53.1%id, 0.0%wa, 0.0%hi, 0.1%si, 0.1%st Mem: 7680000k total, 5774940k used, 1905060k free, 400792k buffers Swap: 2096472k total, 876580k used, 1219892k free, 1727652k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29679 baishou 16 0 1560m 1.1g 18m R 72.0 15.3 115:41.08 java 29678 baishou 15 0 1560m 1.1g 18m R 63.3 15.3 118:44.99 java 29673 baishou 15 0 1560m 1.1g 18m S 1.0 15.3 0:59.72 java 29677 baishou 15 0 1560m 1.1g 18m S 1.0 15.3 1:01.34 java
3. 查看这个线程所有系统调用
strace -p 29679
read(114, " 225 6 10 43 p3651_ 4"..., 2064) = 149 write(114, "7333 6 3201r4 B25274252* 275. "..., 2011) = 2011 write(114, "7333 6 Adddddc2301!4302dQQ3300R373300c"..., 2011) = 2011 write(114, "7333 6 000630561JdK tb1521841 0101200"..., 2011) = 2011 write(114, "7333 6 000630561K627 tb1533113 0101200"..., 2011) = 2011 write(114, "7333 6 <