{"id":7636,"date":"2016-01-10T23:31:12","date_gmt":"2016-01-10T15:31:12","guid":{"rendered":"http:\/\/jpuyy.com\/?p=7636"},"modified":"2016-04-27T21:34:21","modified_gmt":"2016-04-27T13:34:21","slug":"%e4%bd%bf%e7%94%a8-dd-%e6%b5%8b%e8%af%95-io-%e6%80%a7%e8%83%bd","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=7636","title":{"rendered":"\u4f7f\u7528 dd \u6d4b\u8bd5 I\/O \u6027\u80fd"},"content":{"rendered":"<p>\u4f7f\u7528 dd \u5e76\u7ed3\u5408\u4e0d\u540c\u7684\u53c2\u6570\u6d4b\u8bd5 I\/O \u6027\u80fd<\/p>\n<p>\u4e0d\u8981\u5728\u751f\u4ea7\u73af\u5883\u4e0b\u7528 dd \u8fdb\u884c\u64cd\u4f5c\uff0c\u51c6\u5907\u4e00\u4e9b\u6d4b\u8bd5\u73af\u5883\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c\u3002<\/p>\n<p>dd \u53c2\u6570\uff1a<\/p>\n<p>bs=BYTES \u540c\u65f6\u8bfb\u53d6\u548c\u5199\u5165\u7684\u5b57\u8282<\/p>\n<p>\u5199\u6027\u80fd\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u6709\u5982\u4e0b oflag \u7684\u503c\u53ef\u4ee5\u9009\u62e9<\/p>\n<p>\u76f4\u63a5\u5199 ( direct )<br \/>\n\u540c\u6b65\u5199 ( dsync, synchronize )<br \/>\n\u540c\u6b65\u5199 ( sync, \u5305\u542b metadata )<\/p>\n<p>\u5bf9\u4e8e dd \uff0c\u8f93\u5165\u53ef\u4ee5\u662f \/dev\/zero \uff0c\u8f93\u51fa\u53ef\u4ee5\u662f \u7a7a raid \uff0c \u78c1\u76d8\u6216\u5206\u533a\uff0c \u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u6587\u4ef6\u3002\u5f53\u4f7f\u7528\u6587\u4ef6\u65b9\u5f0f\u65f6\u4f1a\u6bd4\u5176\u4ed6\u65b9\u5f0f\u6162\uff0c\u56e0\u4e3a metadata \u4e5f\u8981\u5199\u5165\u3002<\/p>\n<p>\u5f53\u4f7f\u7528 if=\/dev\/zero bs=1G \u7684\u65f6\u5019\uff0c\u9700\u8981\u5185\u5b58\u6709 1G \u7a7a\u4f59\u7a7a\u95f4\u3002<br \/>\n\u8981\u591a\u6b21\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5e76\u6a21\u62df\u65e5\u5e38\u670d\u52a1\u5668\u7684\u5f02\u5e38\u60c5\u51b5\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e9b cron \u4efb\u52a1\u7b49\uff0c\u5982 updatedb \u3002<\/p>\n<p>\u5199 512MB \u6587\u4ef6\uff0c\u53ea\u5199\u4e00\u6b21\uff0c\u4f7f\u7528 oflag=direct\uff0c\u542f\u7528\u786c\u76d8 cache ( hdparm -W1 \/dev\/vda )<\/p>\n<pre>dd if=\/dev\/zero of=\/root\/testfile bs=512MB count=1 oflag=direct<\/pre>\n<p>\u5173\u95ed\u78c1\u76d8 cache ( hdparm -W0 \/dev\/vda )\uff0c\u518d\u6d4b\u4e00\u6b21<\/p>\n<p>\u4f1a\u53d1\u73b0\u5f00 cache \u6bd4\u4e0d\u5f00 cache \u5feb\u5f88\u591a<\/p>\n<p>\u518d\u505a\u5b9e\u9a8c\uff0c\u4f7f\u7528 bs=512 bytes\uff0ccount=1000 \u6765\u5199\u6587\u4ef6\uff0c\u603b\u5927\u5c0f 512 KB\u3002\u8fd9\u6837\u5c31\u6a21\u62df\u4e86\u9891\u7e41\u5199\u78c1\u76d8\u7684\u573a\u666f\uff0c\u540c\u65f6\u6839\u636e\u663e\u793a\u7684\u65f6\u95f4\u5c31\u80fd\u77e5\u9053\u5c0f\u6587\u4ef6\u6bcf\u6b21\u5199\u8bbf\u95ee\u7528\u65f6\u3002<\/p>\n<p>\u53c2\u8003\uff1ahttps:\/\/www.thomas-krenn.com\/en\/wiki\/Linux_I\/O_Performance_Tests_using_dd<\/p>\n<p>\u8865\u5145\uff0c\u4f7f\u7528 dd \u6d4b\u8bd5\u8bfb\u6027\u80fd\uff0c\u9996\u5148\u6e05\u7a7a cache \u7684\u6570\u636e\uff0c\u7136\u540e\u8bfb\u6587\u4ef6\u4e22\u5230 \/dev\/null<\/p>\n<pre>\r\necho 3 > \/proc\/sys\/vm\/drop_caches\r\ndd if=.\/testfile of=\/dev\/null bs=8k\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 dd \u5e76\u7ed3\u5408\u4e0d\u540c\u7684\u53c2\u6570\u6d4b\u8bd5 I\/O \u6027\u80fd \u4e0d\u8981\u5728\u751f\u4ea7\u73af\u5883\u4e0b\u7528 dd \u8fdb\u884c\u64cd\u4f5c\uff0c\u51c6\u5907\u4e00\u4e9b\u6d4b\u8bd5\u73af\u5883\u8fdb\u884c\u5982\u4e0b\u64cd\u4f5c\u3002 dd \u53c2\u6570\uff1a bs=BYTES \u540c\u65f6\u8bfb\u53d6\u548c\u5199\u5165\u7684\u5b57\u8282 \u5199\u6027\u80fd\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u6709\u5982\u4e0b oflag \u7684\u503c\u53ef\u4ee5\u9009\u62e9 \u76f4\u63a5\u5199 ( direct ) \u540c\u6b65\u5199 ( dsync, synchronize ) \u540c\u6b65\u5199 ( sync, \u5305\u542b metadata ) \u5bf9\u4e8e dd \uff0c\u8f93\u5165\u53ef\u4ee5\u662f \/dev\/zero \uff0c\u8f93\u51fa\u53ef\u4ee5\u662f \u7a7a raid \uff0c \u78c1\u76d8\u6216\u5206\u533a\uff0c \u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u6587\u4ef6\u3002\u5f53\u4f7f\u7528\u6587\u4ef6\u65b9\u5f0f\u65f6\u4f1a\u6bd4\u5176\u4ed6\u65b9\u5f0f\u6162\uff0c\u56e0\u4e3a metadata \u4e5f\u8981\u5199\u5165\u3002 \u5f53\u4f7f\u7528 if=\/dev\/zero bs=1G \u7684\u65f6\u5019\uff0c\u9700\u8981\u5185\u5b58\u6709 1G \u7a7a\u4f59\u7a7a\u95f4\u3002 \u8981\u591a\u6b21\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5e76\u6a21\u62df\u65e5\u5e38\u670d\u52a1\u5668\u7684\u5f02\u5e38\u60c5\u51b5\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e9b cron \u4efb\u52a1\u7b49\uff0c\u5982 updatedb \u3002 \u5199 512MB [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-7636","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7636"}],"version-history":[{"count":5,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7636\/revisions"}],"predecessor-version":[{"id":7704,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7636\/revisions\/7704"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}