HDFS中的命令列,HDFS命令列

來源:互聯網
上載者:User

HDFS中的命令列,HDFS命令列

HDFS中的命令列

    本文介紹了HDFS以命令列啟動並執行時候,幾個常用的命令列的作用和如何使用~



1. fs

fs是啟動命令列動作,該命令用於提供一系列子命令。

使用形式為hadoop fs –cmd <args>

其中,cmd是子命令,args是具體的命令操作。

例如hadoop fs –help

或者說fs是其餘子命令的父親,其餘都是在“-cmd”的模式下的!


2. –cat 輸出

hadoop fs –cat URI

將路徑指定的檔案輸出到螢幕


3. –copyFromLocal 將本地檔案複製到HDFS中

hadoop fs -copyFromLocal <localsrc> URI

hadoop fs –copyFromLocal /usr/localFile.txt sample.txt

可以實現本地檔案上傳到HDFS中,而且目標路徑是簡化過的


4. -cp 複製

hadoop fs –cp /usr/file1 /usr/files /user/dir

源路徑的檔案複製到目標路徑中,源路徑可以有多個,但是目標路徑只能有一個


5. –du 顯示目錄中所有檔案的大小,或者一個檔案的大小

hadoop fs –du /usr/dir1


6. –dus 顯示檔案大小
7. –expunge 清空資源回收筒

hadoop fs –expunge


8. –get 複製本件到本地系統

使用方法為:hadoop fs –get <locaodst>

hadoop fs –get /usr/file localfile


9. –put 本地檔案複製到目標檔案系統

使用方式:hadoop fs –put <localsrc> <dst>

hadoop fs –put localfile hadfs://host:port/usr/file


10. –ls 瀏覽本地檔案

使用方法:hadoop fs –ls <arg>

返回資訊:

檔案名稱<副本數> 檔案大小 修改日期 許可權 使用者識別碼/組 ID


11. –lsr 遞迴地查閱檔案內容
12. –mkdir 建立對應的檔案目錄

hadoop fs –mkdir /usr/dir1/dir2/dir3/file


13. –mv 移動

將源檔案移動到目標路徑,目標路徑可以有多個

hadoop fs –mv /usr/file1 /usr/file2


14. –rm 刪除

hadoop fs –rm URI 


15. –rmr 遞迴刪除
16. –Setrep 改變一個副本的複製份數

hadoop fs –setrep –w 3 –R /usr/file


17. –Test 檢查檔案

使用ezd對檔案進行檢查

-e:檢查檔案是否存在,若存在返回0;

-z:檢查檔案是否為0位元組,如果是返回0;

-d:檢查路徑是否為目錄,如果是返回1;


18. –text 將源檔案輸出為文本格式

hadoop fs –text <src> 啟動並執行格式是zip以及Text類







相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.