欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hadoop学习之HDFS命令行操作

程序员文章站 2024-03-23 00:02:10
...

hadoop学习之HDFS命令行操作

[aaa@qq.com ~]# 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命令行操作
原因:没有打开hdfs
解决:hadoop学习之HDFS命令行操作
(2)hadoop fs -put README.txt /
hadoop学习之HDFS命令行操作
测试:
hadoop学习之HDFS命令行操作
(3)hadoop fs -cat /README.txt
== hadoop fs -text /README.txt
hadoop学习之HDFS命令行操作
(4) hadoop fs -copyFromLocal cdh_version.properties /
此时:hadoop学习之HDFS命令行操作
(5)hadoop fs -get /README.txt .
此时:
hadoop学习之HDFS命令行操作
(6)hadoop fs -mkdir /hdfs-testhadoop学习之HDFS命令行操作
此时:hadoop学习之HDFS命令行操作
(7)hadoop fs -mv /README.txt /hdfs-test/
此时:
hadoop学习之HDFS命令行操作
(8)hadoop fs -cp /hdfs-test/README.txt /hdfs-test/README.txt-bak
此时:hadoop学习之HDFS命令行操作
(9)hadoop fs -getmerge /hdfs-test ./t.txt
此时:
hadoop学习之HDFS命令行操作
(10)hadoop fs -rm /cdh_version.properties
此时:hadoop学习之HDFS命令行操作
hadoop学习之HDFS命令行操作
hadoop学习之HDFS命令行操作