2015-04-13 91 views
0

對於下面的命令,需要解釋在Hadoop文件系統

hadoop fs -put foo.txt bar.txt 

操作成功後,哪裏會跳回到bar.txt找到我的本地硬盤驅動器,因爲

  1. 一個燎節點設置?
  2. 僞分佈式設置?

bar.txt仍然會被複制3次備份嗎?

回答

2

bar.txt將被放置在當前的hadoop用戶主目錄
/user/<hadoop-user>按照下面的代碼

@Override 
public Path getHomeDirectory() { 
    return makeQualified(new Path("/user/" + dfs.ugi.getShortUserName())); 
} 

here

  1. 如果羣集是單一節點,它只複製一個即使您將dfs.replication設置爲3,也是因爲Hadoop不會將同一個塊保存在同一個節點上多次。
  2. 僞分佈式模式將使所有hadoop守護進程在同一臺機器上運行。這只不過是單節點集羣。
    它將dfs.replication設置爲3,Hadoop只給你警告。

希望它有幫助!

1

上述fs命令會嘗試將文件foo.txt作爲bar.txt放入當前hdfs中。 hdfs的路徑由操作正在執行的當前用戶決定。這是因爲你沒有提供到目的地的絕對路徑。

如果您將/ user設置爲在hdfs中配置的主目錄,它將採用/ user /的路徑並將文件放置在那裏。

另外,如果hdfs中沒有與當前用戶對應的文件夾,則會失敗,說明文件不存在。

例如當前運行的用戶是「testusr1」。並且上述命令將文件放置在「/ users/testusr1」下。

可以通過執行命令進行驗證#hadoop FS -ls /用戶/

AFAIK這將是應該是相同的僞或單個節點設置。

[[email protected] ~]# hadoop fs -ls /user 
Found 11 items 
drwx------ - root  hdfs   0 2015-04-13 03:59 /user/root 
. 
. 
. 
. 
. 
drwxr-xr-x - root  hdfs   0 2015-04-13 04:18 /user/testusr1 
[[email protected] ~]# 
[[email protected] ~]# su - testusr1 
[[email protected] ~]$ whoami 
testusr1 
[[email protected] ~]$ pwd 
/home/testusr1 
[[email protected] ~]$ ll 
total 7 
-rw-rw-r-- 1 testusr1 testusr1 49 2015-04-13 04:17 foo-testusr2.txt 
[[email protected] ~]$ hadoop fs -put foo-testusr2.txt bar-testusr2.txt 

而對於複製的因素,你可以檢查他與基本的hadoop fs -ls命令的幫助。

[[email protected] ~]$exit 
logout 
[[email protected] ~]# hdfs dfs -ls /user/testusr1 
Found 1 items 
-rw-r--r-- 1 testusr1 hdfs   49 2015-04-13 04:18 /user/testusr1/bar-testusr2.txt 
[[email protected] ~]# 

在上面的示例輸出中,您可以在文件權限後看到數字1。它反映爲1,它是根據我的hdfs配置。