当前位置:   article > 正文

HDFS命令

hdfs fs -test -e
1.创建目录

hadoop fs -mkdir /park01


2.查看目录

hadoop fs -ls /
hadoop fs -lsR / 递归查看

[img]http://dl2.iteye.com/upload/attachment/0124/8843/abfd12cf-fcaf-36c0-a08c-e8a403756c67.png[/img]

3.上传文件
文件路径 hdfs目录路径,即将文件上传的hdfs上的哪个目录中
hadoop fs -put ./file /park01


[img]http://dl2.iteye.com/upload/attachment/0124/8845/e4389b3a-e045-30d0-8205-0c20f93564f5.png[/img]

4.下载文件
hdfs文件路径,下载位置路径,即将hdfs上的文件下载到哪个地址
hadoop fs -get /park01/1.txt ./


[img]http://dl2.iteye.com/upload/attachment/0124/8847/f540e98d-710d-3c01-b2d7-827b45c91ca3.png[/img]

5.删除文件

hadoop fs -rm /park01/1.txt


[img]http://dl2.iteye.com/upload/attachment/0124/8849/358d83b6-6295-3168-bcda-6f7fb7524c2b.png[/img]

6.删除目录

hadoop fs -rmdir /park02

[img]http://dl2.iteye.com/upload/attachment/0124/8851/059e95f3-4f4d-3caf-8cc8-f08861099d73.png[/img]

删除非空目录

hadoop fs -rm -r /park01


[img]http://dl2.iteye.com/upload/attachment/0124/8853/f6fbd1b7-4d60-39e7-a5f1-50abb5051be7.png[/img]


7.查看文件内容

hadoop fs -cat /park01/1.txt


[img]http://dl2.iteye.com/upload/attachment/0124/8855/b2ae6cab-e2b5-3935-ae48-89c8bb34fcc6.png[/img]

hadoop fs -tail /park01/1.txt

8.目录重命名

hadoop fs -mv /park02 /park03


[img]http://dl2.iteye.com/upload/attachment/0124/8857/41622839-a4aa-33ea-8738-e514e59868dc.png[/img]

9.移动文件

hadoop fs -mv /1.txt /park03


[img]http://dl2.iteye.com/upload/attachment/0124/8859/9d2dee7d-cd17-3c5c-a695-d5aad90642ee.png[/img]


10.合并目录下文件内容
将 /park01 目录下的文件合并至3.txt文件内
hadoop fs -getmerge /park01 ./3.txt


[img]http://dl2.iteye.com/upload/attachment/0124/8861/cb6e06be-1998-3c4f-be6c-fd8d19481577.png[/img]

11.创建空白文件

hadoop fs -touch /park03/3.txt


[img]http://dl2.iteye.com/upload/attachment/0124/8863/b98cedc6-02ee-31aa-aa0e-d8dc6d3ea6e0.png[/img]

12.分区查看

hadoop fsck /park01/1.txt -files -blocks -locations -racks


[img]http://dl2.iteye.com/upload/attachment/0124/8995/296d9672-ea48-3f86-bef3-741b5e2265d9.png[/img]

13.进入安全模式

hadoop dfsadmin -safemode enter


[img]http://dl2.iteye.com/upload/attachment/0124/8997/286faec1-bc93-30c7-8fc8-cf2fbc9c146a.png[/img]

安全模式下不允许进行修改


[img]http://dl2.iteye.com/upload/attachment/0124/8999/1d264069-0f5b-3764-8eb0-16ed6b333f7c.png[/img]

14.退出安全模式

hadoop dfsadmin -safemode leave


[img]http://dl2.iteye.com/upload/attachment/0124/9001/3513c28f-4f2d-376c-aedb-71ee3cb2f551.png[/img]
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/510576
推荐阅读
相关标签
  

闽ICP备14008679号