【Hadoop】 2.7.3版本 hdfs 命令行使用

时间:2023-12-26 21:33:49

1.查看HDFS下目录结构及文件

dream361@ubuntu:~$ hdfs dfs -ls -R /

2.创建文件目录/tmp

dream361@ubuntu:~$ hdfs dfs -mkdir /tmp

3.复制当前目录下a.txts到HDFS文件系统

dream361@ubuntu:~$ hdfs dfs -put a.txt /inputFile

4.列出/tmp目录

dream361@ubuntu:~$ hdfs dfs -ls /tmp

5.查看/inputFile/a.txt文件内容

dream361@ubuntu:~$ hdfs dfs -cat /inputFile/a.txt
Not Support zh_CN.UTF-
cannot output Chinese LANGUAGE

6.删除/tmp目录

dream361@ubuntu:~$ hdfs dfs -rm /tmp
rm: `/tmp': Is a directory
dream361@ubuntu:~$ hdfs dfs -rm -r /tmp
// :: INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval =  minutes, Emptier interval =  minutes.
Deleted /tmp

7.查看HDFS状态

dream361@ubuntu:~$ hdfs dfsadmin -report
Configured Capacity:  (13.66 GB)
Present Capacity:  (7.01 GB)
DFS Remaining:  (7.01 GB)
DFS Used:  ( KB)
DFS Used%: 0.00%
Under replicated blocks:
Blocks with corrupt replicas:
Missing blocks:
Missing blocks (with replication factor ): 

-------------------------------------------------
Live datanodes ():

Name:  (localhost)
Hostname: localhost
Decommission Status : Normal
Configured Capacity:  (13.66 GB)
DFS Used:  ( KB)
Non DFS Used:  (6.64 GB)
DFS Remaining:  (7.01 GB)
DFS Used%: 0.00%
DFS Remaining%: 51.36%
Configured Cache Capacity:  ( B)
Cache Used:  ( B)
Cache Remaining:  ( B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers:
Last contact: Sat Feb  :: PST 

8.离开或进入安全模式

dream361@ubuntu:~$ hdfs dfsadmin -safemode leave
Safe mode is OFF
dream361@ubuntu:~$ hdfs dfsadmin -safemode enter
Safe mode is ON