{"id":1228,"date":"2010-03-01T13:13:28","date_gmt":"2010-03-01T05:13:28","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=1228"},"modified":"2024-12-28T11:20:46","modified_gmt":"2024-12-28T03:20:46","slug":"iostat-detail","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2010\/03\/iostat-detail\/","title":{"rendered":"Linux iostat\u76d1\u6d4bIO\u72b6\u6001"},"content":{"rendered":"\n<p>Linux\u7cfb\u7edf\u51fa\u73b0\u4e86\u6027\u80fd\u95ee\u9898\uff0c\u4e00\u822c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7top\u3001iostat\u3001free\u3001vmstat\u7b49\u547d\u4ee4\u6765\u67e5\u770b\u521d\u6b65\u5b9a\u4f4d\u95ee\u9898\u3002\u5176\u4e2diostat\u53ef\u4ee5\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e30\u5bcc\u7684IO\u72b6\u6001\u6570\u636e\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: red;\">1. \u57fa\u672c\u4f7f\u7528<\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$iostat -d -k 1 10<\/code><\/pre>\n\n\n\n<p>\u53c2\u6570 -d \u8868\u793a\uff0c\u663e\u793a\u8bbe\u5907\uff08\u78c1\u76d8\uff09\u4f7f\u7528\u72b6\u6001\uff1b-k\u67d0\u4e9b\u4f7f\u7528block\u4e3a\u5355\u4f4d\u7684\u5217\u5f3a\u5236\u4f7f\u7528Kilobytes\u4e3a\u5355\u4f4d\uff1b1 10\u8868\u793a\uff0c\u6570\u636e\u663e\u793a\u6bcf\u96941\u79d2\u5237\u65b0\u4e00\u6b21\uff0c\u5171\u663e\u793a10\u6b21\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$iostat -d -k 1 10\nDevice:            tps    kB_read\/s    kB_wrtn\/s    kB_read    kB_wrtn\nsda              39.29        21.14         1.44  441339807   29990031\nsda1              0.00         0.00         0.00       1623        523\nsda2              1.32         1.43         4.54   29834273   94827104\nsda3              6.30         0.85        24.95   17816289  520725244\nsda5              0.85         0.46         3.40    9543503   70970116\nsda6              0.00         0.00         0.00        550        236\nsda7              0.00         0.00         0.00        406          0\nsda8              0.00         0.00         0.00        406          0\nsda9              0.00         0.00         0.00        406          0\nsda10            60.68        18.35        71.43  383002263 1490928140\n\nDevice:            tps    kB_read\/s    kB_wrtn\/s    kB_read    kB_wrtn\nsda             327.55      5159.18       102.04       5056        100\nsda1              0.00         0.00         0.00          0          0<\/code><\/pre>\n\n\n\n<p><span style=\"color: blue;\">tps<\/span>\uff1a\u8be5\u8bbe\u5907\u6bcf\u79d2\u7684\u4f20\u8f93\u6b21\u6570\uff08Indicate the number of transfers per second that were issued to the device.\uff09\u3002\u201c\u4e00\u6b21\u4f20\u8f93\u201d\u610f\u601d\u662f\u201c\u4e00\u6b21I\/O\u8bf7\u6c42\u201d\u3002\u591a\u4e2a\u903b\u8f91\u8bf7\u6c42\u53ef\u80fd\u4f1a\u88ab\u5408\u5e76\u4e3a\u201c\u4e00\u6b21I\/O\u8bf7\u6c42\u201d\u3002\u201c\u4e00\u6b21\u4f20\u8f93\u201d\u8bf7\u6c42\u7684\u5927\u5c0f\u662f\u672a\u77e5\u7684\u3002<\/p>\n\n\n\n<p><span style=\"color: blue;\">kB_read\/s<\/span>\uff1a\u6bcf\u79d2\u4ece\u8bbe\u5907\uff08drive expressed\uff09\u8bfb\u53d6\u7684\u6570\u636e\u91cf\uff1b<span style=\"color: blue;\">kB_wrtn\/s<\/span>\uff1a\u6bcf\u79d2\u5411\u8bbe\u5907\uff08drive expressed\uff09\u5199\u5165\u7684\u6570\u636e\u91cf\uff1b<span style=\"color: blue;\">kB_read<\/span>\uff1a\u8bfb\u53d6\u7684\u603b\u6570\u636e\u91cf\uff1b<span style=\"color: blue;\">kB_wrtn<\/span>\uff1a\u5199\u5165\u7684\u603b\u6570\u91cf\u6570\u636e\u91cf\uff1b\u8fd9\u4e9b\u5355\u4f4d\u90fd\u4e3aKilobytes\u3002<\/p>\n\n\n\n<p>\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u78c1\u76d8sda\u4ee5\u53ca\u5b83\u7684\u5404\u4e2a\u5206\u533a\u7684\u7edf\u8ba1\u6570\u636e\uff0c\u5f53\u65f6\u7edf\u8ba1\u7684\u78c1\u76d8\u603bTPS\u662f39.29\uff0c\u4e0b\u9762\u662f\u5404\u4e2a\u5206\u533a\u7684TPS\u3002\uff08\u56e0\u4e3a\u662f\u77ac\u95f4\u503c\uff0c\u6240\u4ee5\u603bTPS\u5e76\u4e0d\u4e25\u683c\u7b49\u4e8e\u5404\u4e2a\u5206\u533aTPS\u7684\u603b\u548c\uff09<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: red;\">2. -x \u53c2\u6570<\/span><\/h4>\n\n\n\n<p>\u4f7f\u7528-x\u53c2\u6570\u6211\u4eec\u53ef\u4ee5\u83b7\u5f97\u66f4\u591a\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">iostat -d -x -k 1 10\nDevice:    rrqm\/s wrqm\/s   r\/s   w\/s  rsec\/s  wsec\/s    rkB\/s    wkB\/s avgrq-sz avgqu-sz   await  svctm  %util\nsda          1.56  28.31  7.80 31.49   42.51    2.92    21.26     1.46     1.16     0.03    0.79   2.62  10.28\nDevice:    rrqm\/s wrqm\/s   r\/s   w\/s  rsec\/s  wsec\/s    rkB\/s    wkB\/s avgrq-sz avgqu-sz   await  svctm  %util\nsda          2.00  20.00 381.00  7.00 12320.00  216.00  6160.00   108.00    32.31     1.75    4.50   2.17  84.20<\/code><\/pre>\n\n\n\n<p><span style=\"color: blue;\">rrqm\/s<\/span>\uff1a\u6bcf\u79d2\u8fd9\u4e2a\u8bbe\u5907\u76f8\u5173\u7684\u8bfb\u53d6\u8bf7\u6c42\u6709\u591a\u5c11\u88abMerge\u4e86\uff08\u5f53\u7cfb\u7edf\u8c03\u7528\u9700\u8981\u8bfb\u53d6\u6570\u636e\u7684\u65f6\u5019\uff0cVFS\u5c06\u8bf7\u6c42\u53d1\u5230\u5404\u4e2aFS\uff0c\u5982\u679cFS\u53d1\u73b0\u4e0d\u540c\u7684\u8bfb\u53d6\u8bf7\u6c42\u8bfb\u53d6\u7684\u662f\u76f8\u540cBlock\u7684\u6570\u636e\uff0cFS\u4f1a\u5c06\u8fd9\u4e2a\u8bf7\u6c42\u5408\u5e76Merge\uff09\uff1bwrqm\/s\uff1a\u6bcf\u79d2\u8fd9\u4e2a\u8bbe\u5907\u76f8\u5173\u7684\u5199\u5165\u8bf7\u6c42\u6709\u591a\u5c11\u88abMerge\u4e86\u3002<\/p>\n\n\n\n<p><span style=\"color: blue;\">rsec\/s<\/span>\uff1a\u6bcf\u79d2\u8bfb\u53d6\u7684\u6247\u533a\u6570\uff1b<span style=\"color: blue;\">wsec\/<\/span>\uff1a\u6bcf\u79d2\u5199\u5165\u7684\u6247\u533a\u6570\u3002<span style=\"color: blue;\">r\/s<\/span>\uff1aThe number of read requests that were issued to the device per second\uff1b<span style=\"color: blue;\">w\/s<\/span>\uff1aThe number of write requests that were issued to the device per second\uff1b<\/p>\n\n\n\n<p><span style=\"color: blue;\">await<\/span>\uff1a\u6bcf\u4e00\u4e2aIO\u8bf7\u6c42\u7684\u5904\u7406\u7684\u5e73\u5747\u65f6\u95f4\uff08\u5355\u4f4d\u662f<del datetime=\"2011-03-01T08:00:29+00:00\">\u5fae\u79d2<\/del>\u6beb\u79d2\uff09\u3002\u8fd9\u91cc\u53ef\u4ee5\u7406\u89e3\u4e3aIO\u7684\u54cd\u5e94\u65f6\u95f4\uff0c\u4e00\u822c\u5730\u7cfb\u7edfIO\u54cd\u5e94\u65f6\u95f4\u5e94\u8be5\u4f4e\u4e8e5ms\uff0c\u5982\u679c\u5927\u4e8e10ms\u5c31\u6bd4\u8f83\u5927\u4e86\u3002<\/p>\n\n\n\n<p><span style=\"color: blue;\">%util<\/span>\uff1a\u5728\u7edf\u8ba1\u65f6\u95f4\u5185\u6240\u6709\u5904\u7406IO\u65f6\u95f4\uff0c\u9664\u4ee5\u603b\u5171\u7edf\u8ba1\u65f6\u95f4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7edf\u8ba1\u95f4\u96941\u79d2\uff0c\u8be5\u8bbe\u5907\u67090.8\u79d2\u5728\u5904\u7406IO\uff0c\u800c0.2\u79d2\u95f2\u7f6e\uff0c\u90a3\u4e48\u8be5\u8bbe\u5907\u7684%util = 0.8\/1 = 80%\uff0c\u6240\u4ee5\u8be5\u53c2\u6570\u6697\u793a\u4e86\u8bbe\u5907\u7684\u7e41\u5fd9\u7a0b\u5ea6\u3002\u4e00\u822c\u5730\uff0c\u5982\u679c\u8be5\u53c2\u6570\u662f100%\u8868\u793a\u8bbe\u5907\u5df2\u7ecf\u63a5\u8fd1\u6ee1\u8d1f\u8377\u8fd0\u884c\u4e86\uff08\u5f53\u7136\u5982\u679c\u662f\u591a\u78c1\u76d8\uff0c\u5373\u4f7f%util\u662f100%\uff0c\u56e0\u4e3a\u78c1\u76d8\u7684\u5e76\u53d1\u80fd\u529b\uff0c\u6240\u4ee5\u78c1\u76d8\u4f7f\u7528\u672a\u5fc5\u5c31\u5230\u4e86\u74f6\u9888\uff09\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: red;\">3. -c \u53c2\u6570<\/span><\/h4>\n\n\n\n<p>iostat\u8fd8\u53ef\u4ee5\u7528\u6765\u83b7\u53d6cpu\u90e8\u5206\u72b6\u6001\u503c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">iostat -c 1 10\navg-cpu:  %user   %nice    %sys %iowait   %idle\n           1.98    0.00    0.35   11.45   86.22\navg-cpu:  %user   %nice    %sys %iowait   %idle\n           1.62    0.00    0.25   34.46   63.67<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: red;\">4. \u5e38\u89c1\u7528\u6cd5<\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">iostat -d -k 1 10        #\u67e5\u770bTPS\u548c\u541e\u5410\u91cf\u4fe1\u606f\niostat -d -x -k 1 10      #\u67e5\u770b\u8bbe\u5907\u4f7f\u7528\u7387\uff08%util\uff09\u3001\u54cd\u5e94\u65f6\u95f4\uff08await\uff09\niostat -c 1 10            #\u67e5\u770bcpu\u72b6\u6001<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: red;\">5. \u5b9e\u4f8b\u5206\u6790<\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ iostat -d -k 1 |grep sda10\nDevice:            tps    kB_read\/s    kB_wrtn\/s    kB_read    kB_wrtn   \nsda10            60.72        18.95        71.53  395637647 1493241908\nsda10           299.02      4266.67       129.41       4352        132\nsda10           483.84      4589.90      4117.17       4544       4076\nsda10           218.00      3360.00       100.00       3360        100\nsda10           546.00      8784.00       124.00       8784        124\nsda10           827.00     13232.00       136.00      13232        136<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u770b\u5230\uff0c\u78c1\u76d8\u6bcf\u79d2\u4f20\u8f93\u6b21\u6570\u5e73\u5747\u7ea6400\uff1b\u6bcf\u79d2\u78c1\u76d8\u8bfb\u53d6\u7ea65MB\uff0c\u5199\u5165\u7ea61MB\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">iostat -d -x -k 1\nDevice:    rrqm\/s wrqm\/s   r\/s   w\/s  rsec\/s  wsec\/s    rkB\/s    wkB\/s avgrq-sz avgqu-sz   await  svctm  %util\nsda          1.56  28.31  7.84 31.50   43.65    3.16    21.82     1.58     1.19     0.03    0.80   2.61  10.29\nsda          1.98  24.75 419.80  6.93 13465.35  253.47  6732.67   126.73    32.15     2.00    4.70   2.00  85.25\nsda          3.06  41.84 444.90 54.08 14204.08 2048.98  7102.04  1024.49    32.57     2.10    4.21   1.85  92.24<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u78c1\u76d8\u7684\u5e73\u5747\u54cd\u5e94\u65f6\u95f4&lt;5ms\uff0c\u78c1\u76d8\u4f7f\u7528\u7387&gt;80\u3002\u78c1\u76d8\u54cd\u5e94\u6b63\u5e38\uff0c\u4f46\u662f\u5df2\u7ecf\u5f88\u7e41\u5fd9\u4e86\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u53c2\u8003\u6587\u732e<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Linux man iostat<\/li>\n\n\n\n<li><a href=\"http:\/\/www.xaprb.com\/blog\/2010\/01\/09\/how-linux-iostat-computes-its-results\/\">How Linux iostat computes its results<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/www.mjmwired.net\/kernel\/Documentation\/iostats.txt\">Linux iostat<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u7cfb\u7edf\u51fa\u73b0\u4e86\u6027\u80fd\u95ee\u9898\uff0c\u4e00\u822c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7top\u3001iostat\u3001free\u3001vmstat\u7b49\u547d\u4ee4\u6765\u67e5\u770b\u521d\u6b65\u5b9a\u4f4d\u95ee\u9898\u3002\u5176\u4e2diostat\u53ef\u4ee5\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e30\u5bcc\u7684IO\u72b6\u6001\u6570\u636e\u3002 1. \u57fa\u672c\u4f7f\u7528 \u53c2\u6570 -d \u8868\u793a\uff0c\u663e\u793a\u8bbe\u5907\uff08\u78c1\u76d8\uff09\u4f7f\u7528\u72b6\u6001\uff1b-k\u67d0\u4e9b\u4f7f\u7528block\u4e3a\u5355\u4f4d\u7684\u5217\u5f3a\u5236\u4f7f\u7528Kilobytes\u4e3a\u5355\u4f4d\uff1b1 10\u8868\u793a\uff0c\u6570\u636e\u663e\u793a\u6bcf\u96941\u79d2\u5237\u65b0\u4e00\u6b21\uff0c\u5171\u663e\u793a10\u6b21\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[27,4],"tags":[121],"class_list":["post-1228","post","type-post","status-publish","format-standard","hentry","category-linux","category-code-detail","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=1228"}],"version-history":[{"count":24,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1228\/revisions"}],"predecessor-version":[{"id":16923,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1228\/revisions\/16923"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=1228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=1228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=1228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}