找出Linux下面哪個進程最耗iowait

來源:互聯網
上載者:User
1. 找出CPU佔用率高的線程:ps H -eo user,pid,ppid,tid,time,psr,%cpu,cmd --sort=%cpu參數'H'顯示線程相關的資訊,格式輸出中包含:user,pid,ppid,tid,time,%cpu,cmd,然後再用%cpu欄位進行排序2. 找出耗iowait的進程先停掉syslogservice syslog stop開啟block dump:echo 1 > /proc/sys/vm/block_dump多次運行,查看結果dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head排前的比較佔用io抓完後關掉block_dump和啟動syslog:echo 0 > /proc/sys/vm/block_dumpservice syslog start實踐發現,這樣找出的進程一般為kjournald、pdflush、kswapd0。3. pidstat# pidstat -d 5Linux 2.6.26-2-openvz-686 (pro-12-gl.savonix.com)   10/29/2009  _i686_  (2 CPU)11:19:41 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command11:19:46 PM      1895      0.00     23.06      0.00  kjournald11:19:46 PM      7309      0.00      0.80      0.00  syslog-ng11:19:46 PM     21404      0.00      0.80      0.00  tlsmgr11:19:46 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command11:19:51 PM     18208      0.00      0.80      0.00  syslog-ng11:19:51 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command11:19:56 PM      1895      0.00      9.60      0.00  kjournald11:19:56 PM     17120      0.00      1.60      0.00  tlsmgr11:19:56 PM     27257      0.00      1.60      0.00  apache211:19:56 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command11:20:01 PM       423      0.00      0.80      0.00  apache211:20:01 PM      1851      0.00      0.80      0.00  nginx11:20:01 PM      1895      0.00      8.80      0.00  kjournald然後可以使用top命令查看進程對應的物理CPU:執行top後,按f,再選擇j: P Last used cpu (SMP) ,再按斷行符號回到top介面註:進程kjournald、pdflush、kswapd0的作用1.kswapd0Linux uses kswapd for virtual memory management such that pages that have been recently accessed are kept in memory and less active pages are paged out to disk.(what is a page?)…Linux uses manages memory in units called pages.So,the kswapd process regularly decreases the ages of unreferenced pages…and at the end they are paged out(moved out) to disk系統每過一定時間就會喚醒kswapd,看看記憶體是否緊張,如果不緊張,則睡眠,在kswapd中,有2個閥值,pages_hige和pages_low,當空閑記憶體頁的數量低於pages_low的時候,kswapd進程就會掃描記憶體並且每次釋放出32個free pages,直到free page的數量到達pages_high.2.kjournaldEXT3檔案系統的日誌進程,具有3種模式:journal - logs all filesystem data and metadata changes. The slowest of the three ext3 journaling modes, this journaling mode minimizes the chance of losing the changes you have made to any file in an ext3 filesystem.(記錄所有檔案系統上的中繼資料改變,最慢的一種模式,)ordered - only logs changes to filesystem metadata, but flushes file data updates to disk before making changes to associated filesystem metadata. This is the default ext3 journaling mode.(預設使用的模式,只記錄檔案系統改變的中繼資料,並在改變之前記錄日誌)writeback - only logs changes to filesystem metadata but relies on the standard filesystem write process to write file data changes to disk. This is the fastest ext3 journaling mode.(最快的一種模式,同樣只記錄修改過的中繼資料,依賴標準檔案系統寫進程將資料寫到硬碟)修改模式EXT3的工作模式;vim /etc/fstab/dev/hda5      /opt            ext3       data=writeback        1 0詳細介紹:http://www.linuxplanet.com/linuxplanet/reports/4136/5/3.pdflushpdflush用於將記憶體中的內容和檔案系統進行同步,比如說,當一個檔案在記憶體中進行修改,pdflush負責將它寫回硬碟.每當記憶體中的垃圾頁(dirty page)超過10%的時候,pdflush就會將這些頁面備份回硬碟.這個比率是可調節的,通過/etc/sysctl.conf中的 vm.dirty_background_ratio項 預設值為10 也可以cat /proc/sys/vm/dirty_background_ratio 查看當前的值
相關文章

聯繫我們

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