注,其实常用命令不用网上搜,和linux下的命令很类似,触类旁通,直接在linux 上 hadoop fs 看一下就行了,不需要刻意去记
我把 linux 上的 help 列举下,方便直接看吧,hdfs dfs 与 hadoop fs 效果一样
常用的就是
hdfs dfs -copyFromLocal /local/data /hdfs/data:将本地文件上传到 hdfs 上(原路径只能是一个文件)
hdfs dfs -put /tmp/ /hdfs/ :和 copyFromLocal 区别是,put 原路径可以是文件夹等
hadoop fs -ls / :查看根目录文件
hadoop fs -ls /tmp/data:查看/tmp/data目录
hadoop fs -cat /tmp/a.txt :查看 a.txt,与 -text 一样
hadoop fs -mkdir dir:创建目录dir
hadoop fs -rmr dir:删除目录dir
1 [orco@node1 sbin]$ hadoop fs 2 Usage: hadoop fs [generic options] 3 [-appendToFile <localsrc> ... <dst>] 4 [-cat [-ignoreCrc] <src> ...] 5 [-checksum <src> ...] 6 [-chgrp [-R] GROUP PATH...] 7 [-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...] 8 [-chown [-R] [OWNER][:[GROUP]] PATH...] 9 [-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>] 10 [-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] 11 [-count [-q] [-h] <path> ...] 12 [-cp [-f] [-p | -p[topax]] <src> ... <dst>] 13 [-createSnapshot <snapshotDir> [<snapshotName>]] 14 [-deleteSnapshot <snapshotDir> <snapshotName>] 15 [-df [-h] [<path> ...]] 16 [-du [-s] [-h] <path> ...] 17 [-expunge] 18 [-find <path> ... <expression> ...] 19 [-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] 20 [-getfacl [-R] <path>] 21 [-getfattr [-R] {-n name | -d} [-e en] <path>] 22 [-getmerge [-nl] <src> <localdst>] 23 [-help [cmd ...]] 24 [-ls [-d] [-h] [-R] [<path> ...]] 25 [-mkdir [-p] <path> ...] 26 [-moveFromLocal <localsrc> ... <dst>] 27 [-moveToLocal <src> <localdst>] 28 [-mv <src> ... <dst>] 29 [-put [-f] [-p] [-l] <localsrc> ... <dst>] 30 [-renameSnapshot <snapshotDir> <oldName> <newName>] 31 [-rm [-f] [-r|-R] [-skipTrash] <src> ...] 32 [-rmdir [--ignore-fail-on-non-empty] <dir> ...] 33 [-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]] 34 [-setfattr {-n name [-v value] | -x name} <path>] 35 [-setrep [-R] [-w] <rep> <path> ...] 36 [-stat [format] <path> ...] 37 [-tail [-f] <file>] 38 [-test -[defsz] <path>] 39 [-text [-ignoreCrc] <src> ...] 40 [-touchz <path> ...] 41 [-truncate [-w] <length> <path> ...] 42 [-usage [cmd ...]]