tail -f /var/log/messages
环境: Ubuntu
1. 开启IO监控
sudo sysctl vm.block_dump=1
2. IO监控开启后,系统将记录程序对所有硬盘块的访问,通过dmesg查看
dmesg
[442825.284270] mysqld(11600): READ block 6676888 on xvdb2 (8 sectors)
[442825.289893] mysqld(11600): READ block 11543240 on xvdb2 (8 sectors)
[442825.291317] mysqld(11600): READ block 11543248 on xvdb2 (24 sectors)
3. 使用awk汇总,得到占用磁盘最多的进程
dmesg |awk -F " " '{print $2}'|sort|uniq -c|sort -rn|head -n 100
1564 mysqld(11600):
994 python(11474):
302 nginx(6171):
136 mysqld(29743):
126 mysqld(15528):
71 ntpd(772):
62 mysqld(16837):
4. 调试完毕后,别忘了关闭IO监控。
sudo sysctl vm.block_dump=1
摘自:http://www.luochunhui.com/linux-io-dmesg/
参考:http://blog.slogra.com/post-317.html
实践:
[root@my htdocs]# vi /proc/sys/vm/block_dump
[root@my htdocs]# sysctl vm.block_dump=1
vm.block_dump = 1
[root@my htdocs]# dmesg |awk -F: '{print $1}'|sort|uniq -c|sort -rn|head -n 10
195 ACPI
194 pci 0000
63 alloc kstat_irqs on node 0
53 pnp 00
48 ioatdma 0000
34 igb 0000
34 EDAC sbridge
29 flush-253
26 SRAT
24 pci_bus 0000
[root@my htdocs]# sysctl vm.block_dump=0
vm.block_dump = 0
环境: Ubuntu
1. 开启IO监控
sudo sysctl vm.block_dump=1
2. IO监控开启后,系统将记录程序对所有硬盘块的访问,通过dmesg查看
dmesg
[442825.284270] mysqld(11600): READ block 6676888 on xvdb2 (8 sectors)
[442825.289893] mysqld(11600): READ block 11543240 on xvdb2 (8 sectors)
[442825.291317] mysqld(11600): READ block 11543248 on xvdb2 (24 sectors)
3. 使用awk汇总,得到占用磁盘最多的进程
dmesg |awk -F " " '{print $2}'|sort|uniq -c|sort -rn|head -n 100
1564 mysqld(11600):
994 python(11474):
302 nginx(6171):
136 mysqld(29743):
126 mysqld(15528):
71 ntpd(772):
62 mysqld(16837):
4. 调试完毕后,别忘了关闭IO监控。
sudo sysctl vm.block_dump=1
摘自:http://www.luochunhui.com/linux-io-dmesg/
参考:http://blog.slogra.com/post-317.html
实践:
[root@my htdocs]# vi /proc/sys/vm/block_dump
[root@my htdocs]# sysctl vm.block_dump=1
vm.block_dump = 1
[root@my htdocs]# dmesg |awk -F: '{print $1}'|sort|uniq -c|sort -rn|head -n 10
195 ACPI
194 pci 0000
63 alloc kstat_irqs on node 0
53 pnp 00
48 ioatdma 0000
34 igb 0000
34 EDAC sbridge
29 flush-253
26 SRAT
24 pci_bus 0000
[root@my htdocs]# sysctl vm.block_dump=0
vm.block_dump = 0
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/6919/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2024-4-23 16:55
评论列表