1 sar 命令查看以后磁盘 IO 读写
sar(System Activity Reporter 系统活动状况报告)是 Linux 上最为全面的零碎性能剖析工具之一,能够从多方面对系统的流动进行报告,包含:文件的读写状况、零碎调用的应用状况、磁盘I/O、CPU效率、内存应用情况、过程流动等。
(1)sar 工具装置
yum install sysstat
(2)sar 查看磁盘IO读写状况
# 查看以后磁盘 IO 读写,每 1 秒显示 1 次 显示 10次。sar -b 1 10
- tps # 每秒向磁盘设施申请数据的次数,包含读、写申请,为 rtps 与 wtps 的和。出于效率思考,每一次 IO 下发后并不是立刻解决申请,而是将申请合并,这里 tps 指申请合并后的申请计数
- rtps # 每秒向磁盘设施的读申请次数
- wtps # 每秒向磁盘设施的写申请次数
- bread # 每秒从磁盘读的 bytes 数量
- bwrtn # 每秒向磁盘写的 bytes 数量
2 iotop 命令查看磁盘 IO 性能
iotop 命令是一个用来监督磁盘 I/O 应用情况的工具。iotop 是过程级别 IO 监控。
(1)iotop 工具装置
yum install iotop
(2)iotop 的罕用用例
- iotop -o # 只显示正在产生 IO 的过程或线程;
- iotop -d 3 -n 5 # 工夫距离 3 秒,输入 5 次;
- iotop -botq -p 8382 # 输入 pid 为 8382 的过程 IO 状况
(3)iotop 可选参数阐明
Options: --version show program's version number and exit -h, --help show this help message and exit -o, --only only show processes or threads actually doing I/O -b, --batch non-interactive mode -n NUM, --iter=NUM number of iterations before ending [infinite] -d SEC, --delay=SEC delay between iterations [1 second] -p PID, --pid=PID processes/threads to monitor [all] -u USER, --user=USER users to monitor [all] -P, --processes only show processes, not all threads -a, --accumulated show accumulated I/O instead of bandwidth -k, --kilobytes use kilobytes instead of a human friendly unit -t, --time add a timestamp on each line (implies --batch) -q, --quiet suppress some lines of header (implies --batch)
3 磁盘性能压测工具 fio
(1)fio 工具装置
yum install fio
(2)IOPS 压测示例
(/data/test 这个是压测数据读写目录)
fio -directory=/data/test -direct=1 -iodepth 10 -thread -rw=randwrite -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=180 -group_reporting -name=rand_write
(3)带宽压测
(/data/test 这个是压测数据读写目录)
fio -directory=/data/test -direct=1 -iodepth 10 -thread -rw=randwrite -ioengine=psync -bs=4096k -size=2G -numjobs=10 -runtime=180 -group_reporting -name=rand_write
4 iostat 的罕用用例
iostat 是零碎级别的 IO 监控,而 iotop 是过程级别 IO 监控。
iostat -d -k 1 10 #查看TPS和吞吐量信息(磁盘读写速度单位为KB)iostat -d -m 2 #查看TPS和吞吐量信息(磁盘读写速度单位为MB)iostat -d -x -k 1 10 #查看设施使用率(%util)、响应工夫(await) iostat -c 1 10 #查看cpu状态
5 简略验证磁盘是否故障
在指标磁盘上 touch 一个空文件看看,是否磁盘故障导致无奈写入。
6 查看文件属于哪个盘
查看文件属于哪个盘
df /data/
7 附录
sar应用:https://www.cnblogs.com/zcx-python/p/9001630.htmliostat 应用:https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858810.htmlIO测试工具之fio详解:https://www.cnblogs.com/raykuan/p/6914748.html
8 小结
磁盘 IO 性能监控/压测工具罕用的有 sar、iotop、fio、iostat 。这篇文章只是简略记录波及相干命令的应用,不做过多具体的深刻应用实际阐明,只是起到一个简略的抛砖引玉。
「不甩锅的码农」原创,转载请注明起源,未经受权禁止商业用途!同名 GZH 请关注!