{"id":181,"date":"2018-03-12T14:04:19","date_gmt":"2018-03-12T06:04:19","guid":{"rendered":"http:\/\/www.max-shu.com\/blog\/?p=181"},"modified":"2018-03-12T14:04:19","modified_gmt":"2018-03-12T06:04:19","slug":"hadoop%e6%80%a7%e8%83%bd%e6%a8%a1%e5%9e%8b%ef%bc%884%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.max-shu.com\/blog\/?p=181","title":{"rendered":"Hadoop\u6027\u80fd\u6a21\u578b\uff084\uff09"},"content":{"rendered":"<p><span style=\"font-size: large;\"><b>3 Reduce\u4efb\u52a1\u9636\u6bb5\u6027\u80fd\u6a21\u578b<\/b><\/span><\/p>\n<p>Reduce\u4efb\u52a1\u5206\u4e3a\u56db\u4e2a\u9636\u6bb5\uff1a<br \/>\n1. Shuffle\uff1a \u4ecemap\u8282\u70b9\u62f7\u8d1dmap\u8f93\u51fa\u5230reduce\u8282\u70b9\uff0c\u9700\u8981\u7684\u8bdd\u89e3\u538b\u7f29\uff0c\u8be5\u9636\u6bb5\u53ef\u80fd\u4f1a\u6709\u90e8\u5206merge\u3002<br \/>\n2. Merge\uff1a\u4ece\u4e0d\u540c\u7684mappers\u5408\u5e76\u6392\u5e8f\u7684\u5206\u7247\uff0c\u5f62\u6210reduce\u51fd\u6570\u7684\u8f93\u5165\u3002<br \/>\n3. Reduce\uff1a\u6267\u884c\u7528\u6237\u63d0\u4f9b\u7684reduce\u51fd\u6570\u3002<br \/>\n4. Write\uff1a\u5199\u8f93\u51fa\u5230HDFS\uff0c\u9700\u8981\u7684\u8bdd\u538b\u7f29\u3002<\/p>\n<p><span style=\"font-size: medium;\"><b>3.1 Shuffle\u9636\u6bb5\u6a21\u578b<\/b><\/span><\/p>\n<p>\u4e0b\u9762\u7684\u8ba8\u8bba\u57fa\u4e8e\u5355\u4e2areduce\u4efb\u52a1\uff0c\u5728shuffle\u9636\u6bb5\uff0c\u6846\u67b6\u4ece\u6bcf\u4e2amapper\u53d6\u5f97map\u8f93\u51fa\u5206\u7247\uff0c\u62f7\u8d1d\u5230reduce\u8282\u70b9\u3002\u5047\u5982map\u8f93\u51fa\u88ab\u538b\u7f29\uff0c\u5219\u9700\u8981\u89e3\u538b\uff0c\u6bcf\u4e2amap\u5206\u7247\u5230\u8fbereduce\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-182\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-26.png\" alt=\"\" width=\"897\" height=\"157\" \/><br \/>\n\u8fd9\u91cc\u7684intermDataSize\u548cintermDataPairs\u662f\u5355\u4e2amapper\u7684\u4e2d\u95f4\u8f93\u51fa\u7684\u6570\u636e\u5927\u5c0f\u548ck\uff0dv\u5bf9\u6570\u3002<br \/>\n\u5355\u4e2areduce\u53d6\u5f97\u7684\u6570\u636e\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-183\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-27.png\" alt=\"\" width=\"894\" height=\"79\" \/><br \/>\n\u6570\u636e\u62f7\u8d1d\u5230reduce\u540e\uff0c\u653e\u5728shuffle buffer\u5185\u5b58\u7684\u5927\u5c0f\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-184\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-28.png\" alt=\"\" width=\"894\" height=\"31\" \/><br \/>\n\u5f53\u5185\u5b58\u5927\u5c0f\u8fbe\u5230\u95e8\u9650\uff0c\u6216\u5206\u7247\u6570\u5927\u4e8epInMemMergeThr\uff0c\u8fd9\u4e9b\u5206\u7247\u88ab\u5408\u5e76\uff0c\u968f\u5373spill\u5230\u78c1\u76d8\uff0c\u5efa\u7acb\u65b0\u7684spill\u6587\u4ef6\uff08\u6587\u4ef6\u540d\u4e3ashuffleFile\uff09\uff0c\u5408\u5e76\u95e8\u9650\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-185\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-29.png\" alt=\"\" width=\"896\" height=\"37\" \/><br \/>\n\u7136\u800c\uff0c\u5f53\u5206\u7247\u5927\u5c0f\u5927\u4e8eshuffleBufferSize\u768425\uff05\uff0c\u8fd9\u4e2a\u5206\u7247\u5c06\u76f4\u63a5\u5199\u5165\u78c1\u76d8\uff0c\u800c\u4e0d\u9700\u8981\u7ecf\u8fc7\u5185\u5b58\uff08\u8fdb\u4e00\u6b65\uff0c\u6ca1\u6709\u5185\u5b58\u5408\u5e76\u9636\u6bb5\uff09\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-186\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-30.png\" alt=\"\" width=\"949\" height=\"283\" \/><\/p>\n<p>\u4e00\u4e2ashuffle\u6587\u4ef6\u5408\u5e76numSegInShuffleFile\u4e2a\u5206\u7247\uff0c\u5982\u679c\u6709combine\u529f\u80fd\uff0c\u5728\u5408\u5e76\u671f\u95f4\u4f7f\u7528\uff0c\u6ce8\u610f\uff0c\u5047\u5982numSegInShuffleFile\u5927\u4e8enumMappers\uff0c\u5219\u4e0d\u7528\u5408\u5e76\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-187\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-31.png\" alt=\"\" width=\"904\" height=\"260\" \/><br \/>\n\u5728\u5408\u5e76\u7684\u6700\u540e\uff0c\u4e00\u4e9b\u5206\u7247\u4e5f\u8bb8\u7559\u5728\u5185\u5b58\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-188\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-32.png\" alt=\"\" width=\"960\" height=\"357\" \/><br \/>\n\u5f53shuffle\u6587\u4ef6\u6570\u91cf\u8d85\u8fc7\u4e00\u5b9a\u95e8\u9650\uff082XpSortFactor\uff0d1\uff09\uff0c\u4e00\u4e2a\u65b0\u7684\u5408\u5e76\u7ebf\u7a0b\u4f1a\u88ab\u89e6\u53d1\uff0cpSortFactor\u4e2ashuffle\u6587\u4ef6\u4f1a\u88ab\u5408\u5e76\u6210\u4e00\u4e2a\u66f4\u5927\u7684\u6392\u5e8f\u6587\u4ef6\u3002\u5728\u78c1\u76d8\u5408\u5e76\u671f\u95f4combine\u529f\u80fd\u4e0d\u4f7f\u7528\u3002\u8fd9\u6837\u5b50\u7684merge\u603b\u6570\u662f\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-189\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-33.png\" alt=\"\" width=\"897\" height=\"74\" \/><br \/>\n\u5728shuffle\u9636\u6bb5\u672b\u5c3e\uff0c\u5408\u5e76\u548c\u975e\u5408\u5e76\u7684shuffle\u6587\u4ef6\u90fd\u5c06\u4fdd\u5b58\u4e8e\u78c1\u76d8\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-190\" src=\"http:\/\/www.max-shu.com\/blog\/wp-content\/uploads\/2018\/03\/\u4e0b\u8f7d-34.png\" alt=\"\" width=\"903\" height=\"268\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>3 Reduce\u4efb\u52a1\u9636\u6bb5\u6027\u80fd\u6a21\u578b Reduce\u4efb\u52a1\u5206\u4e3a\u56db\u4e2a\u9636\u6bb5\uff1a 1. Shuffle\uff1a \u4ecemap\u8282\u70b9\u62f7\u8d1dma &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63],"tags":[80,123,122,120,121],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-63","tag-hadoop","tag-hdfs","tag-mapreduce","tag-120","tag-121"],"views":1542,"_links":{"self":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":1,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":191,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions\/191"}],"wp:attachment":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}