{"id":1812,"date":"2020-07-01T05:49:17","date_gmt":"2020-06-30T21:49:17","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1812"},"modified":"2020-07-01T05:49:17","modified_gmt":"2020-06-30T21:49:17","slug":"hdfs%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1812","title":{"rendered":"HDFS\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"<div>\n<div>\n<div>\u4ecb\u7ecd\uff1a<\/div>\n<\/div>\n<\/div>\n<article>\n<ul>\n<li>HDFS \u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u76f8\u5f53\u591a\u7684shell \u64cd\u4f5c\u547d\u4ee4\uff0c\u5927\u5927\u65b9\u4fbf\u4e86\u7a0b\u5e8f\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u4eba\u5458\u67e5\u770b\u3001\u4fee\u6539HDFS \u4e0a\u7684\u6587\u4ef6\u3002\u8fdb\u4e00\u6b65\uff0cHDFS \u7684\u64cd\u4f5c\u547d\u4ee4\u548cUnix\/Linux \u7684\u547d\u4ee4\u540d\u79f0\u548c\u683c\u5f0f\u76f8\u5f53\u4e00\u81f4\uff0c\u56e0\u800c\u5b66\u4e60HDFS \u547d\u4ee4\u7684\u6210\u672c\u4e5f\u5927\u4e3a\u7f29\u5c0f\u3002<\/li>\n<\/ul>\n<h5>1.\u547d\u4ee4\u5e2e\u52a9<\/h5>\n<div>\n<pre>[hadoop@hadoop000 ~]$ hdfs dfs\nUsage: hadoop fs [generic options]\n        [-appendToFile &lt;localsrc&gt; ... &lt;dst&gt;]\n        [-cat [-ignoreCrc] &lt;src&gt; ...]\n        [-checksum &lt;src&gt; ...]\n        [-chgrp [-R] GROUP PATH...]\n        [-chmod [-R] &lt;MODE[,MODE]... | OCTALMODE&gt; PATH...]\n        [-chown [-R] [OWNER][:[GROUP]] PATH...]\n        [-copyFromLocal [-f] [-p] [-l] [-d] &lt;localsrc&gt; ... &lt;dst&gt;]\n        [-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] &lt;src&gt; ... &lt;localdst&gt;]\n        [-count [-q] [-h] [-v] [-t [&lt;storage type&gt;]] [-u] [-x] &lt;path&gt; ...]\n        [-cp [-f] [-p | -p[topax]] [-d] &lt;src&gt; ... &lt;dst&gt;]\n        [-createSnapshot &lt;snapshotDir&gt; [&lt;snapshotName&gt;]]\n        [-deleteSnapshot &lt;snapshotDir&gt; &lt;snapshotName&gt;]\n        [-df [-h] [&lt;path&gt; ...]]\n        [-du [-s] [-h] [-x] &lt;path&gt; ...]\n        [-expunge]\n        [-find &lt;path&gt; ... &lt;expression&gt; ...]\n        [-get [-f] [-p] [-ignoreCrc] [-crc] &lt;src&gt; ... &lt;localdst&gt;]\n        [-getfacl [-R] &lt;path&gt;]\n        [-getfattr [-R] {-n name | -d} [-e en] &lt;path&gt;]\n        [-getmerge [-nl] [-skip-empty-file] &lt;src&gt; &lt;localdst&gt;]\n        [-help [cmd ...]]\n        [-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [&lt;path&gt; ...]]\n        [-mkdir [-p] &lt;path&gt; ...]\n        [-moveFromLocal &lt;localsrc&gt; ... &lt;dst&gt;]\n        [-moveToLocal &lt;src&gt; &lt;localdst&gt;]\n        [-mv &lt;src&gt; ... &lt;dst&gt;]\n        [-put [-f] [-p] [-l] [-d] &lt;localsrc&gt; ... &lt;dst&gt;]\n        [-renameSnapshot &lt;snapshotDir&gt; &lt;oldName&gt; &lt;newName&gt;]\n        [-rm [-f] [-r|-R] [-skipTrash] [-safely] &lt;src&gt; ...]\n        [-rmdir [--ignore-fail-on-non-empty] &lt;dir&gt; ...]\n        [-setfacl [-R] [{-b|-k} {-m|-x &lt;acl_spec&gt;} &lt;path&gt;]|[--set &lt;acl_spec&gt; &lt;path&gt;]]\n        [-setfattr {-n name [-v value] | -x name} &lt;path&gt;]\n        [-setrep [-R] [-w] &lt;rep&gt; &lt;path&gt; ...]\n        [-stat [format] &lt;path&gt; ...]\n        [-tail [-f] &lt;file&gt;]\n        [-test -[defsz] &lt;path&gt;]\n        [-text [-ignoreCrc] &lt;src&gt; ...]\n        [-touchz &lt;path&gt; ...]\n        [-truncate [-w] &lt;length&gt; &lt;path&gt; ...]\n        [-usage [cmd ...]]\n# \u6ce8\uff1ahdfs dfs\u7b49\u540c\u4e8ehadoop fs\n<\/pre>\n<\/div>\n<h5>2.\u6587\u4ef6\u64cd\u4f5c\u547d\u4ee4\u6848\u4f8b<\/h5>\n<blockquote><p>hdfs dfs -copyFromLocal \/local\/data \/hdfs\/data\uff1a\u5c06\u672c\u5730\u6587\u4ef6\u4e0a\u4f20\u5230 hdfs \u4e0a\uff08\u539f\u8def\u5f84\u53ea\u80fd\u662f\u4e00\u4e2a\u6587\u4ef6\uff09<br \/>\nhdfs dfs -put \/tmp\/ \/hdfs\/ \uff1a\u548c copyFromLocal \u533a\u522b\u662f\uff0cput \u539f\u8def\u5f84\u53ef\u4ee5\u662f\u6587\u4ef6\u5939\u7b49<br \/>\nhadoop fs -ls \/ \uff1a\u67e5\u770b\u6839\u76ee\u5f55\u6587\u4ef6<br \/>\nhadoop fs -ls \/tmp\/data\uff1a\u67e5\u770b\/tmp\/data\u76ee\u5f55<br \/>\nhadoop fs -cat \/tmp\/a.txt \uff1a\u67e5\u770b a.txt\uff0c\u4e0e -text \u4e00\u6837<br \/>\nhadoop fs -mkdir dir\uff1a\u521b\u5efa\u76ee\u5f55dir<br \/>\nhadoop fs -get \/aaa\/jdk.tar.gz :\u7b49\u540c\u4e8ecopyToLocal\uff0c\u5c31\u662f\u4ecehdfs\u4e0b\u8f7d\u6587\u4ef6\u5230\u672c\u5730<br \/>\nhadoop fs -df -h \/ :\u7edf\u8ba1\u6587\u4ef6\u7cfb\u7edf\u7684\u53ef\u7528\u7a7a\u95f4\u4fe1\u606f<br \/>\nhadoop fs -cp \/aaa\/jdk.tar.gz \/bbb\/jdk.tar.gz.2 :\u4ecehdfs\u7684\u4e00\u4e2a\u8def\u5f84\u62f7\u8d1dhdfs\u7684\u53e6\u4e00\u4e2a\u8def\u5f84<br \/>\nhadoop fs -mv \/aaa\/jdk.tar.gz \/ :\u5728hdfs\u76ee\u5f55\u4e2d\u79fb\u52a8\u6587\u4ef6<br \/>\nhadoop fs -du -s -h \/aaa\/* :\u7edf\u8ba1\u6587\u4ef6\u5939\u7684\u5927\u5c0f\u4fe1\u606f<br \/>\nhadoop fs -rm -r \/aaa\/bbb\/ :\u5220\u9664\u6587\u4ef6\u6216\u6587\u4ef6\u5939<br \/>\nhadoop fs -rmdir \/aaa\/bbb\/ccc :\u5220\u9664\u76ee\u5f55<br \/>\nhadoop fs -tail \/weblog\/access_log.1 :\u663e\u793a\u4e00\u4e2a\u6587\u4ef6\u7684\u672b\u5c3e<\/p><\/blockquote>\n<h5>3.\u7ba1\u7406\u547d\u4ee4<\/h5>\n<div>\n<pre># \u547d\u4ee4\u5e2e\u52a9\n[hadoop@hadoop000 ~]$ hdfs dfsadmin\nUsage: hdfs dfsadmin\nNote: Administrative commands can only be run as the HDFS superuser.\n        [-report [-live] [-dead] [-decommissioning]]\n        [-safemode &lt;enter | leave | get | wait&gt;]\n        [-saveNamespace]\n        [-rollEdits]\n        [-restoreFailedStorage true|false|check]\n        [-refreshNodes]\n        [-setQuota &lt;quota&gt; &lt;dirname&gt;...&lt;dirname&gt;]\n        [-clrQuota &lt;dirname&gt;...&lt;dirname&gt;]\n        [-setSpaceQuota &lt;quota&gt; [-storageType &lt;storagetype&gt;] &lt;dirname&gt;...&lt;dirname&gt;]\n        [-clrSpaceQuota [-storageType &lt;storagetype&gt;] &lt;dirname&gt;...&lt;dirname&gt;]\n        [-finalizeUpgrade]\n        [-rollingUpgrade [&lt;query|prepare|finalize&gt;]]\n        [-refreshServiceAcl]\n        [-refreshUserToGroupsMappings]\n        [-refreshSuperUserGroupsConfiguration]\n        [-refreshCallQueue]\n        [-refresh &lt;host:ipc_port&gt; &lt;key&gt; [arg1..argn]\n        [-reconfig &lt;datanode|...&gt; &lt;host:ipc_port&gt; &lt;start|status|properties&gt;]\n        [-printTopology]\n        [-refreshNamenodes datanode_host:ipc_port]\n        [-deleteBlockPool datanode_host:ipc_port blockpoolId [force]]\n        [-setBalancerBandwidth &lt;bandwidth in bytes per second&gt;]\n        [-getBalancerBandwidth &lt;datanode_host:ipc_port&gt;]\n        [-fetchImage &lt;local directory&gt;]\n        [-allowSnapshot &lt;snapshotDir&gt;]\n        [-disallowSnapshot &lt;snapshotDir&gt;]\n        [-shutdownDatanode &lt;datanode_host:ipc_port&gt; [upgrade]]\n        [-evictWriters &lt;datanode_host:ipc_port&gt;]\n        [-getDatanodeInfo &lt;datanode_host:ipc_port&gt;]\n        [-metasave filename]\n        [-triggerBlockReport [-incremental] &lt;datanode_host:ipc_port&gt;]\n        [-help [cmd]]\n<\/pre>\n<\/div>\n<blockquote><p>hdfs dfsadmin -report :\u663e\u793a\u6240\u6709dataNode<br \/>\nhdfs dfsadmin -safemode leave :\u79bb\u5f00\u5b89\u5168\u6a21\u5f0f<\/p><\/blockquote>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7ecd\uff1a HDFS \u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u76f8\u5f53\u591a\u7684shell \u64cd\u4f5c\u547d\u4ee4\uff0c\u5927\u5927\u65b9\u4fbf\u4e86\u7a0b\u5e8f\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u4eba\u5458\u67e5\u770b\u3001\u4fee\u6539HDFS &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1812\"> <span class=\"screen-reader-text\">HDFS\u5e38\u7528\u547d\u4ee4<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[135],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"\u4ecb\u7ecd\uff1a HDFS \u6587\u4ef6\u7cfb\u7edf\u63d0\u4f9b\u4e86\u76f8\u5f53\u591a\u7684shell \u64cd\u4f5c\u547d\u4ee4\uff0c\u5927\u5927\u65b9\u4fbf\u4e86\u7a0b\u5e8f\u5458\u548c\u7cfb\u7edf\u7ba1\u7406\u4eba\u5458\u67e5\u770b\u3001\u4fee\u6539HDFS&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1812"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1812"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1812\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1812"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}