Linux命令操作HDFS檔案系統
阿新 • • 發佈:2018-12-26
HDFS命令操作
# 格式化操作 $ bin/hdfs namenode -format # 展示檔案和資料夾列表 $ bin/hdfs dfs -ls / # 建立資料夾 # 在使用者目錄下建立 $ bin/hdfs dfs -mkdir AAA/ # 在根目錄下建立 $ bin/hdfs dfs -mkdir /AAA/ # 遞迴層級建立多個資料夾 $ bin/hdfs dfs -mkdir -p /BBB/CCC # 上傳本地檔案到HDFS,如果上傳成功,則刪除本地檔案(就是剪下操作) $ bin/hdfs dfs -moveFromLocal hello_world.txt / # 末尾追加資料到HDFS中已經存在的檔案裡面 $ bin/hdfs dfs -appendToFile hello_world2.txt /hello_world.txt # 檢視檔案內容 $ bin/hdfs dfs -cat /hello_world.txt # 檢視檔案末尾資訊 $ bin/hdfs dfs -tail /hello_world.txt # 拷貝本地檔案到HDFS,-copyFromLocal可以替換為-put $ bin/hdfs dfs -copyFromLocal words.txt /AAA # 拷貝HDFS檔案到HDFS另一個目錄 $ bin/hdfs dfs -cp /AAA/words.txt /BBB # 或剪下 $ bin/hdfs dfs -mv /AAA/words.txt /BBB # 下載HDFS中的檔案到本地檔案系統 $ bin/hdfs -get /hello_world.txt ./ # 下載多個檔案,併合併為一個檔案到本地檔案系統 $ bin/hdfs dfs -getmerge /*.txt ./demo.txt # 刪除檔案或資料夾 $ bin/hdfs dfs -rmr /AAA