伺服器CPU使用率過高排查與解決思路,cpu排查

來源:互聯網
上載者:User

伺服器CPU使用率過高排查與解決思路,cpu排查

探索服務器的cpu使用率特別高

排查思路:

-使用top或者mpstat查看cpu的使用方式
# mpstat -P ALL 2 1
Linux 2.6.32-358.el6.x86_64 (linux—host) 01/05/2016 _x86_64_(24 CPU)

04:41:13 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
04:41:15 PM all 0.56 0.00 0.25 0.00 0.00 0.04 0.00 0.00 99.14
04:41:15 PM 0 3.08 0.00 1.03 0.00 0.00 0.51 0.00 0.00 95.38
04:41:15 PM 1 1.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 98.00
04:41:15 PM 2 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00
04:41:15 PM 3 1.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 98.51
04:41:15 PM 4 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 5 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00
04:41:15 PM 6 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00
04:41:15 PM 7 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 8 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00
04:41:15 PM 9 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 10 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 11 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 12 1.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 98.00
04:41:15 PM 13 1.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 98.00
04:41:15 PM 14 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 15 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 16 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 17 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 18 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 19 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50
04:41:15 PM 20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 21 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 22 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
04:41:15 PM 23 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.50

-top找出佔用高的進程ID

-查看進程佔用線程數量,如java:
# ps -eLf|grep java|wc -l
1065

解決CPU使用不均或者使用過高的問題

taskset

taskset是LINUX提供的一個命令(ubuntu系統可能需要自行安裝,schedutils package)。他可以讓某個程式運行在某個(或)某些CPU上。

1)顯示進程啟動並執行CPU

# taskset -p 3495
pid 3495's current affinity mask: ffffffff


註:顯示結果的ffffffff實際上是二進位32個低位均為1的bitmask,每個1對應於1個CPU,表示該進程在32個CPU上運行

2)指定進程運行在某個特定的CPU上

# taskset -pc 3 3495

顯示結果:

pid 3495's current affinity list: 0-31
pid 3495's new affinity list: 3

註:3表示CPU將只會運行在第4個CPU上(從0開始計數)

3)進程啟動時指定CPU

# taskset -c 1 ./redis-server ../redis.conf

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.