IO负载高来源定位pt-ioprofile

1.使用top -d 1 查看%wa是否有等待IO完成的cpu时间,简单理解就是指cpu等待磁盘写入完成的时间;IO等待所占用的cpu时间的百分比,高过30%时IO压力高;

2.使用iostat -d -x 1 输出(-x表示显示和io相关的扩展数据);

3.使用iotop定位负载来源工具具体查看IO负载主要是落在哪个进程上了;如何规避IO负载过高的问题呢?具体问题具体分析:
 1)如果你的服务器用来做日志分析,要避免多个crontab交叠执行导致多进程随机IO(参考:随机IO vs 顺序IO),避免定期的压缩、解压大日志(这种任务会造成某段时间的IO抖动)。
 2)如果是前端应用服务器,要避免程序频繁打本地日志、或者异常日志等。
 3)如果是存储服务(mysql、nosql),尽量将服务部署在单独的节点上,不要和其它服务共用,甚至服务本身做读写分离以降低读写压力;调优一些buffer参数以降低IO写的频率等等。另外还可以参考LevelDB这种将随机IO变顺序IO的经典方式。

附IO参考资料:
http://oplinux.com/order/iostat.html
http://bencane.com/2012/08/06/troubleshooting-high-io-wait-in-linux/

IO负载高来源定位

准备工具:

iotop: http://guichaz.free.fr/iotop/

pt-ioprofile:http://www.percona.com/downloads/percona-toolkit/2.2.1/

4.pt-ioprofile定位负载来源文件,通过ps找出负载较高的进程

   pt-ioprofile的原理是对某个pid附加一个strace进程进行IO分析。以下是摘自官网的一段警示:

   However, it works by attaching strace to the process using ptrace(), which will make it run very slowly until strace detaches. In addition to freezing the server, there is also some risk of the process crashing or performing badly after strace detaches from it, or indeed of strace not detaching cleanly and leaving the process in a sleeping state. As a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.

命令格式:pt-ioprofile  --profile -pid=xxx 

                  pt-ioprofile  --profile -pid=xxx  --cell=sizes   

注:对于定位问题更有用的是通过IO的吞吐量来进行定位。使用参数 --cell=sizes,该参数将结果已 B/s 的方式展示出来

原文地址:https://www.cnblogs.com/Alexr/p/9361481.html