hadoop学习之HDFS命令行操作_hdfs

[root@hadoop000 ~]# hadoop fs
Usage: hadoop fs [generic options]
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>]
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] [-v] [-x] <path> ...]
[-cp [-f] [-p | -p[topax]] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] [-x] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] <src> <localdst>]
[-help [cmd ...]]
[-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-usage [cmd ...]]

Generic options supported are
-conf <configuration file> specify an application configuration file
-D <property=value> use value for given property
-fs <local|namenode:port> specify a namenode
-jt <local|resourcemanager:port> specify a ResourceManager
-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines.

The general command line syntax is
bin/hadoop command [genericOptions] [commandOptions]

使用练习:

(1)hadoop fs -ls /

出现错误:

hadoop学习之HDFS命令行操作_hadoop_02


原因:没有打开hdfs

解决:

hadoop学习之HDFS命令行操作_hdfs_03


(2)hadoop fs -put README.txt /

hadoop学习之HDFS命令行操作_hive_04


测试:

hadoop学习之HDFS命令行操作_hive_05


(3)hadoop fs -cat /README.txt

== hadoop fs -text /README.txt

hadoop学习之HDFS命令行操作_hadoop_06


(4) hadoop fs -copyFromLocal cdh_version.properties /

此时:

hadoop学习之HDFS命令行操作_hadoop_07


(5)hadoop fs -get /README.txt .

此时:

hadoop学习之HDFS命令行操作_hadoop_08


(6)hadoop fs -mkdir /hdfs-test

hadoop学习之HDFS命令行操作_hive_09


此时:

hadoop学习之HDFS命令行操作_hive_10


(7)hadoop fs -mv /README.txt /hdfs-test/

此时:

hadoop学习之HDFS命令行操作_大数据_11


(8)hadoop fs -cp /hdfs-test/README.txt /hdfs-test/README.txt-bak

此时:

hadoop学习之HDFS命令行操作_hdfs_12


(9)hadoop fs -getmerge /hdfs-test ./t.txt

此时:

hadoop学习之HDFS命令行操作_hadoop_13


(10)hadoop fs -rm /cdh_version.properties

此时:

hadoop学习之HDFS命令行操作_hive_14


hadoop学习之HDFS命令行操作_hive_15


hadoop学习之HDFS命令行操作_hdfs_16