伺服器問題排查常用命令

來源:互聯網
上載者:User

標籤:linux   jvm   記憶體   cpu   伺服器   

1、top
查看系統負載情況,load average
CPU使用方式,按1查看每個CPU的使用方式
shift+h  查看每個線程的情況

2、free -m  
按兆為單位輸出記憶體的已用,未用,總共等結果
             total       used       free     shared    buffers     cached
Mem:         32176      27911       4265          0        132       7114
-/+ buffers/cache:      20664      11512
Swap:        31996          0      31996

3、查看伺服器磁碟使用方式
df -h
檔案系統              容量  已用 可用 已用% 掛載點
/dev/sda3             510G  317G  168G  66% /
/dev/sda1             996M   40M  905M   5% /boot
tmpfs                  16G     0   16G   0% /dev/shm
查看具體是哪個目錄磁碟使用過大
du -h --max-depth=1 /etc/

4、查看java進程
ps -ef | grep java


5、查看佔用CPU最大的線程
ps Hh -eo pid,tid,pcpu |sort -nk3|tail
 2858  2889  1.0
 2858  3982  1.8
 6796  7480  2.2
查看對應線程的堆棧
jstack  6796 | grep -C 10 ‘nid=0x1d38‘
注意 7480 ---> 十六進位 1D38  ---> 小寫

6、查看記憶體對象
jmap -histo:live pid |head -n 20 

7、查看gc情況:
jstat -gcutil <pid> <頻率> 次數
-rbash-3.2$ jstat -gcutil 6796 1000 3
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
  0.00  26.80  19.02  76.18  21.64   1607   90.868     4   15.923  106.791
  0.00  26.80  23.08  76.18  21.64   1607   90.868     4   15.923  106.791
  0.00  26.80  26.21  76.18  21.64   1607   90.868     4   15.923  106.791
  
8、產生記憶體堆棧檔案
jmap -dump:format=b,file=/soft/dump/mem_dump.bin pid 
tar -czf mem_dump.tar.gz mem_dump.bin 

可通過Eclipse的MemoryAnalyzer工具分析


JVM相關:  http://www.cnblogs.com/redcreen/tag/jvm/


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.