1. 程式人生 > >【Hadoop】 2.7.3版本 hdfs 命令列使用

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

1.檢視HDFS下目錄結構及檔案

[email protected]:~$ hdfs dfs -ls -R /
2.建立檔案目錄/tmp
[email protected]:~$ hdfs dfs -mkdir /tmp
3.複製當前目錄下a.txts到HDFS檔案系統
[email protected]:~$ hdfs dfs -put a.txt /inputFile
4.列出/tmp目錄
[email protected]:~$ hdfs dfs -ls /tmp

5.檢視/inputFile/a.txt檔案內容

[email protected]:~$ hdfs dfs -cat /inputFile/a.txt
Not Support zh_CN.UTF-8
cannot output Chinese LANGUAGE
6.刪除/tmp目錄
[email protected]:~$ hdfs dfs -rm /tmp
rm: `/tmp': Is a directory
[email protected]:~$ 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狀態

[email protected]:~$ 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.離開或進入安全模式
[email protected]:~$ hdfs dfsadmin -safemode leave
Safe mode is OFF
[email protected]:~$ hdfs dfsadmin -safemode enter
Safe mode is ON