HDFS命令

1、Hadoop中有三种Shell命令方式:
hadoop fs适用于任何不同的文件系统,比如本地文件系统和HDFS文件系统
hadoop dfs只能适用于HDFS文件系统
hdfs dfs跟hadoop dfs的命令作用一样,也只能适用于HDFS文件系统./sbin/stop-dfs.sh

2、HDFS命令格式

hadoop fs [genericOptions] [commandOptions]

3、启动HDFS

/usr/local/hadoop/sbin/start-dfs.sh

/usr/local/hadoop/sbin/stop-dfs.sh

4、hdfs中相对路径和绝对路径

hadoop dfs -ls test 或 hadoop dfs -ls hdfs://localhost:9000/user/hadoop/test

5、HDFS常用命令

hadoop dfs -mkdir test

hadoop dfs -ls test 或 hadoop dfs -ls hdfs://localhost:9000/user/hadoop/test

hadoop dfs -rmr test或hadoop dfs -rm -r test #删除目录或文件

hdfs dfs -cat test/*                                      #查询文件内容

hdfs dfs -put ./etc/hadoop/*.xml test     #将本地文件系统文件或/和目录./etc/hadoop/*.xml放到hdfs目录test中

hadoop fs -copyFromLocal test1 test      #将本地文件系统文件或/和目录./test1放到hdfs目录test中

hdfs dfs -get test ./output         # 将 HDFS 上的 test 文件夹及其内容拷贝到本地文件系统./output

hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep input output 'dfs[a-z.]+'      #运行jar包

posted on 2017-06-06 12:28  ostin  阅读(173)  评论(0)    收藏  举报