hdfs命令行操作

查看文件列表

[root@localhost opt]# hadoop fs -ls /
Found 2 items
drwxr-xr-x   - root supergroup          0 2017-11-18 03:49 /hadoop
drwxr-xr-x   - root supergroup          0 2017-11-18 04:00 /user

创建一个目录,我这里是root账户,会在/user/root/input生成

[root@localhost opt]# hadoop fs -mkdir input
[root@localhost opt]# hadoop fs -ls /user/root
Found 2 items
drwxr-xr-x   - root supergroup          0 2017-11-18 04:12 /user/root/input

删除目录

[root@localhost opt]# hadoop fs -rmr input
Deleted hdfs://192.168.24.136:9000/user/root/input

提交文件

[root@localhost opt]# touch test.txt
[root@localhost opt]# hadoop fs -put test.txt input
[root@localhost opt]# hadoop fs -ls /user/root/input
Found 1 items
-rw-r--r--   3 root supergroup          0 2017-11-18 04:19 /user/root/input/test.txt
[root@localhost opt]# 

获取文件到当前目录

[root@localhost opt]# hadoop fs -get input/test.txt test.txt

获取HDFS的状态信息

[root@localhost opt]# hadoop dfsadmin -report
Configured Capacity: 18645180416 (17.36 GB)
Present Capacity: 11589984256 (10.79 GB)
DFS Remaining: 11589943296 (10.79 GB)
DFS Used: 40960 (40 KB)
DFS Used%: 0%
Under replicated blocks: 1
Blocks with corrupt replicas: 0
Missing blocks: 0

-------------------------------------------------
Datanodes available: 1 (1 total, 0 dead)

Name: 192.168.24.136:50010
Decommission Status : Normal
Configured Capacity: 18645180416 (17.36 GB)
DFS Used: 40960 (40 KB)
Non DFS Used: 7055196160 (6.57 GB)
DFS Remaining: 11589943296(10.79 GB)
DFS Used%: 0%
DFS Remaining%: 62.16%
Last contact: Sat Nov 18 04:24:03 PST 2017

你可能感兴趣的:(hadoop)