使用 iostat 工具得到
Device r/s w/s rkB/s wkB/s rrqm/s wrqm/s %rrqm %wrqm r_await w_await aqu-sz rareq-sz wareq-sz svctm %util
nvme1n1 169.31 887.13 1398.02 33160.40 0.00 0.00 0.00 0.00 0.10 0.04 0.00 8.26 37.38 0.46 48.81
nvme0n1 0.00 393.07 0.00 16352.48 0.00 0.00 0.00 0.00 0.00 0.04 0.00 0.00 41.60 0.61 24.16
sdg 0.00 5.94 0.00 63.37 0.00 0.00 0.00 0.00 0.00 0.17 0.00 0.00 10.67 0.50 0.30
sda 0.00 478.22 0.00 1916.83 0.00 1.98 0.00 0.41 0.00 226.81 108.22 0.00 4.01 0.33 15.54
sdb 0.00 466.34 0.00 1865.35 0.00 0.99 0.00 0.21 0.00 200.84 93.43 0.00 4.00 0.31 14.55
sdc 0.00 515.84 0.00 2067.33 0.00 0.99 0.00 0.19 0.00 197.62 101.69 0.00 4.01 0.31 15.74
sdd 0.00 385.15 0.00 1540.59 0.00 0.00 0.00 0.00 0.00 246.85 94.88 0.00 4.00 0.30 11.39
sde 0.00 407.92 0.00 1635.64 0.00 0.00 0.00 0.00 0.00 233.53 95.06 0.00 4.01 0.31 12.57
sdf 0.00 363.37 0.00 1461.39 0.00 1.98 0.00 0.54 0.00 256.83 93.14 0.00 4.02 0.30 10.99
sdh 0.00 815.84 0.00 3263.37 0.00 0.99 0.00 0.12 0.00 112.18 91.11 0.00 4.00 0.44 35.74
sdk 0.00 977.23 0.00 3912.87 0.00 0.99 0.00 0.10 0.00 88.88 86.39 0.00 4.00 0.40 39.50
sdj 0.00 1219.80 0.00 4887.13 0.00 1.98 0.00 0.16 0.00 80.57 97.69 0.00 4.01 0.35 42.48
sdi 0.00 768.32 0.00 3077.23 0.00 0.99 0.00 0.13 0.00 122.81 93.97 0.00 4.01 0.53 40.40
查看进程io cat /proc/131037/io
rchar: 125119 //在read(),pread(),readv(),sendfile等系统调用中读取的字节数
wchar: 632 //在write(),pwrite(),writev(),sendfile等系统调用中写入的字节数
syscr: 111 //调用read(),pread(),readv(),sendfile等系统调用的次数
syscw: 79 //调用write(),pwrite(),writev(),sendfile等系统调用的次数
read_bytes: 425984 //进程读取的物理I/O字节数,包括mmap pagein,在submit_bio()中统计的
write_bytes: 0 //进程写出的物理I/O字节数,包括mmap pageout,在submit_bio()中统计的
cancelled_write_bytes: 0 //如果进程截短了cache中的文件,事实上就减少了原本要发生的写I/O
根据 io 请求分析一个nvme不应该这么的,同时这个读哪来的。
看看对应的进程情况 pidstat -d 1 -p 131037
07:15:14 AM UID PID kB_rd/s kB_wr/s kB_ccwr/s iodelay Command
07:15:15 AM 0 131037 352.00 12556.00 0.00 0 ceph-osd
07:15:16 AM 0 131037 376.00 14532.00 0.00 0 ceph-osd
07:15:17 AM 0 131037 356.00 14608.00 0.00 0 ceph-osd
07:15:18 AM 0 131037 200.00 9016.00 0.00 0 ceph-osd
07:15:19 AM 0 131037 360.00 13748.00 0.00 0 ceph-osd
07:15:20 AM 0 131037 340.00 12700.00 0.00 0 ceph-osd
07:15:21 AM 0 131037 24124.00 40780.00 0.00 0 ceph-osd
07:15:22 AM 0 131037 102100.00 79316.00 0.00 0 ceph-osd
07:15:23 AM 0 131037 103488.00 78680.00 0.00 0 ceph-osd
07:15:24 AM 0 131037 109624.00 79796.00 0.00 0 ceph-osd
07:15:25 AM 0 131037 107692.00 81460.00 0.00 0 ceph-osd
07:15:26 AM 0 131037 111776.00 79172.00 0.00 0 ceph-osd
07:15:27 AM 0 131037 100364.00 146044.00 0.00 0 ceph-osd
07:15:28 AM 0 131037 111536.00 79836.00 0.00 0 ceph-osd
07:15:29 AM 0 131037 63176.00 106344.00 0.00 0 ceph-osd
07:15:30 AM 0 131037 26660.00 29676.00 0.00 0 ceph-osd
07:15:31 AM 0 131037 356.00 13132.00 0.00 0 ceph-osd
07:15:32 AM 0 131037 548.00 13488.00 0.00 0 ceph-osd
07:15:33 AM 0 131037 312.00 10784.00 0.00 0 ceph-osd
07:15:34 AM 0 131037 412.00 13336.00 0.00 0 ceph-osd
07:15:35 AM 0 131037 564.00 13972.00 0.00 0 ceph-osd
怎么有这些读操作呢
开始定位函数
先安装内核 debug
yum install kernel-debuginfo
使用stap 打印一下,看看都是谁在读数据
10987129 rocksdb:low2(129685): <- __x64_sys_pread64
11007817 rocksdb:low2(129685): <- __x64_sys_pread64
11028596 rocksdb:low2(129685): <- __x64_sys_pread64
11049623 rocksdb:low2(129685): <- __x64_sys_pread64
11070259 rocksdb:low2(129685): <- __x64_sys_pread64
11092255 rocksdb:low2(129685): <- __x64_sys_pread64
11187056 rocksdb:low2(129685): <- __x64_sys_pread64
11212132 rocksdb:low2(129685): <- __x64_sys_pread64
11234568 rocksdb:low2(129685): <- __x64_sys_pread64
11236079 rocksdb:low2(129685): <- __x64_sys_pread64
11236375 rocksdb:low2(129685): <- __x64_sys_pread64
看到这大概就知道是因为合并文件带来的问题。