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-8 cannot output Chinese LANGUAGE
6.删除/tmp目录
dream361@ubuntu:~$ hdfs dfs -rm /tmp rm: `/tmp': Is a directory dream361@ubuntu:~$ hdfs dfs -rm -r /tmp 17/02/25 19:38:25 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes. Deleted /tmp
7.查看HDFS状态
dream361@ubuntu:~$ hdfs dfsadmin -report Configured Capacity: 14662287360 (13.66 GB) Present Capacity: 7529889792 (7.01 GB) DFS Remaining: 7529844736 (7.01 GB) DFS Used: 45056 (44 KB) DFS Used%: 0.00% Under replicated blocks: 0 Blocks with corrupt replicas: 0 Missing blocks: 0 Missing blocks (with replication factor 1): 0 ------------------------------------------------- Live datanodes (1): Name: 127.0.0.1:50010 (localhost) Hostname: localhost Decommission Status : Normal Configured Capacity: 14662287360 (13.66 GB) DFS Used: 45056 (44 KB) Non DFS Used: 7132397568 (6.64 GB) DFS Remaining: 7529844736 (7.01 GB) DFS Used%: 0.00% DFS Remaining%: 51.36% Configured Cache Capacity: 0 (0 B) Cache Used: 0 (0 B) Cache Remaining: 0 (0 B) Cache Used%: 100.00% Cache Remaining%: 0.00% Xceivers: 1 Last contact: Sat Feb 25 19:41:39 PST 2017
8.离开或进入安全模式
dream361@ubuntu:~$ hdfs dfsadmin -safemode leave Safe mode is OFF dream361@ubuntu:~$ hdfs dfsadmin -safemode enter Safe mode is ON