美文网首页
io性能分析工具-iostat

io性能分析工具-iostat

作者: 大风过岗 | 来源:发表于2020-12-08 16:02 被阅读0次

linux-io性能分析

iostat (input/output statistics) 是一个linux系统监视工具,它可以用于收集并展示操作系统存储的输入、输出统计。它经常用于识别存储设备(本地磁盘、远程磁盘)的性能问题。

man手册说明

iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.

iostat 可以针对CPU生成统计信息,同时也可以为设备和分区生成IO统计。

语法:

iostat [-选项] [interval] [count]
其中:
interval指示了每间隔多少秒输出一次统计报告,count指示了总共输出多少次统计报告。
例如: iostat 2 3 即为: 每隔2秒输出一次统计报告,共输出3次。
命令的输出结果如下:

[root@iZb1210589viotftelmrcx2Z ~]# iostat 2 3
Linux 3.10.0-957.21.3.el7.x86_64 (iZbp10j40viotftelmrcx2Z)      12/08/2020      _x86_64_        (8 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.05    0.00    0.16    0.31    0.00   98.48

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda             117.95        68.18       665.39   21871116  213457718

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.06    0.00    0.13    0.44    0.00   98.37

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda             160.50         0.00       738.00          0       1476

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.75    0.00    0.12    0.25    0.00   98.88

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda              93.50         0.00       528.00          0       1056

[root@iZb1210589viotftelmrcx2Z ~]# 

选项参数说明:

选项简称 相关 含义
-c CPU 展示CPU使用率
-d device 展示设备的使用率
-h human 以人类可读的形式展示设备使用率
-k kilobytes 以kb为单位展示每秒的统计信息
-m megabytes 以mb为单位展示每秒的统计信息
-N name 展示已注册的设备映射器的名称
-p partitions 展示分区信息
-t time 每次展示时,打印时间信息
-v version 打印版本信息
-x extended 展示扩展的统计信息

输出说明

iostat命令可以用于生成俩种类型的报告,一种是cpu的使用率报告,另一种是设备的使用率报告。

CPU使用率报告

iostat命令最先输出的是cpu使用率报告。对于有多个处理器的系统来说,所统计的值是所有cpu的平均值,报告的形式如下:

字段 含义
%user Show the percentage of CPU utilization that occurred while executing at the user level (application)
%nice Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.
%system Show the percentage of CPU utilization that occurred while executing at the system level (kernel).
%iowait Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%steal Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
%idle Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

其中:
%iowait 和 %idle 都反映了cpu的空闲时间占比,不同的是%iowait反映的是cpu由于等待io操作而处于空闲状态,它是一种非正常的空闲。而%idle指的是cpu由于没有任务执行而处于空闲状态。

设备使用率报告
iostat命令产生的第二个报告就是设备使用率报告,设备报告反映了单个物理设备或分区的使用情况。我们可以在命令行中指定块设备或者分区。如果指定块设备/分区,默认就展示所有系统上所有设备的统计。

字段 中文含义 英文原文
tps 发送到设备的每秒的传输数,一次传输就是一次到设备的IO请求,多个逻辑请求可以被合成单个的IO请求发送到设备上 Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeter‐ minate size
Blk_read/s 每秒从设备读取的块数 Indicate the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second.Blocks are equivalent to sectors and therefore have a size of 512 bytes.
Blk_wrtn/s 每秒向设备写入的块数 Indicate the amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second.
Blk_read 读取的总块数 The total number of blocks (kilobytes, megabytes) read.
Blk_wrtn 写入的总块数 The total number of blocks (kilobytes, megabytes) written.
rrqm/s 每秒合并的读请求 The number of read requests merged per second that were queued to the device.
wrqm/s 每秒合并的写请求 The number of write requests merged per second that were queued to the device.
r/s 该设备每秒完成的读请求(合并后的) The number (after merges) of read requests completed per second for the device.
w/s 该设备每秒完成的写请求(合并后的) The number (after merges) of write requests completed per second for the device
rsec/s 每秒从该设备读取的分区数 The number of sectors (kilobytes, megabytes) read from the device per second.
wsec/s 每秒从该设备写入的分区数 The number of sectors (kilobytes, megabytes) written to the device per second.
avgrq-sz 发送到该设备的平均请求(以分区数计) The average size (in sectors) of the requests that were issued to the device.
avgqu-sz 发送到该设备的请求的平均队列长度 The average queue length of the requests that were issued to the device.
await IO请求的平均等待时间(包括请求在队列中的时间和服务该IO请求消耗的时间,毫秒值) The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
r_await 读请求的等待时间(包括请求在队列中的时间和服务该IO请求消耗的时间,毫秒值) The average time (in milliseconds) for read requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them
w_await 写请求的平均等待时间 The average time (in milliseconds) for write requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
svctm IO请求的平均服务时间 The average service time (in milliseconds)
%util 表示磁盘的繁忙程度,对于SSD来说此项指标不能说明磁盘繁忙 Percentage of elapsed time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100% for devices serving requests serially. But for devices serving requests in parallel, such as RAID arrays and modern SSDs, this number does not reflect their performance limits

常用命令示例:

iostat -d 2

iostat -d 2

以两秒为间隔连续性地展示设备的统计情况

iostat -d 2 6

iostat -d 2 6

输出所有设备的统计报告,每隔两秒统计一次,共统计6次。

iostat -x sda sdb 2 6

iostat -x sda sdb 2 6

每隔两秒输出一次sda和sdb设备的带有扩展信息的统计报告

iostat -p sda 2 6

iostat -p sda 2 6

每隔两秒输出一次sda及其分区的统计报告

iostat -x /dev/vda1 2 2

[root@iZb1210589viotftelmrcx2Z ~]# iostat -p -x /dev/vda1  2 2
Linux 3.10.0-957.21.3.el7.x86_64 (iZbp10j40viotftelmrcx2Z)      12/08/2020      _x86_64_        (8 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.05    0.00    0.16    0.31    0.00   98.49

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.47     5.14    1.28  116.69    68.61   666.04    12.45     0.92    0.96   21.64    0.73   7.14  84.22
vda1              0.47     5.14    1.28   61.48    68.61   666.04    23.41     0.11    1.77   21.64    1.35   0.44   2.77

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.06    0.00    0.19    0.44    0.00   98.31

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     4.00    0.00  157.00     0.00   692.00     8.82     0.95    0.30    0.00    0.30   5.97  93.70
vda1              0.00     4.00    0.00   86.50     0.00   692.00    16.00     0.05    0.53    0.00    0.53   0.40   3.45

[root@iZb1210589viotftelmrcx2Z ~]# 


[root@iZb1210589viotftelmrcx2Z ~]# iostat -d -k 1 1
Linux 3.10.0-957.21.3.el7.x86_64 (iZbp10j40viotftelmrcx2Z)      12/08/2020      _x86_64_        (8 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda             117.97        68.57       666.01   21736464  211109566

[root@iZb1210589viotftelmrcx2Z ~]# iostat -d -k 1 3
Linux 3.10.0-957.21.3.el7.x86_64 (iZbp10j40viotftelmrcx2Z)      12/08/2020      _x86_64_        (8 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda             117.97        68.57       666.00   21736464  211114678

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda             220.00         0.00       936.00          0        936

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda              97.00         0.00       524.00          0        524

[root@iZb1210589viotftelmrcx2Z ~]# 

磁盘性能指标

一般使用以下指标衡量硬盘的性能:

IOPS:每秒读/写次数,单位为次(计数)。存储设备的底层驱动类型决定了不同的 IOPS。
吞吐量: 每秒的读写数据量,单位为MB/s。
时延: I/O 操作的发送时间到接收确认所经过的时间,单位为秒。

IOPS

IOPS

IOPS (Input/Output Per Second)即每秒的输入输出量(或读写次数),是衡量磁盘性能的主要指标之一。IOPS是指单位时间内系统能处理的I/O请求数量,一般以每秒处理的I/O请求数量为单位,I/O请求通常为读或写数据操作请求。

image.png

参考文献

iostat
iops

相关文章

网友评论

      本文标题:io性能分析工具-iostat

      本文链接:https://www.haomeiwen.com/subject/ebxqgktx.html