1. 程式人生 > >Hadoop常用命令引數介紹

Hadoop常用命令引數介紹

常用命令
- help
功能:輸出這個命令引數手冊
- ls
功能:顯示目錄資訊
示例:hadoop fs -ls hdfs://hadoop-hello/
備註:這些引數中,所有的hdfs路徑都可以簡寫–>hadoop fs -ls /等同於上一條命令效果
- mkdir
功能:在hdfs上常見目錄
示例:hadoop fs -mkdir -p /aa/bb/cc
- moveFromLocal
功能:從本地剪下貼上到hdfs
示例:hadoop fs -moveFromLocal /home/hadoop/a.txt /aa/bb/cc
- moveToLocal
功能:從hdfs剪下貼上到本地
示例:hadoop fs -moveToLocal /aa/bb/cc /home/hadoop/a.txt
- appendToFile
功能:追加一個檔案到已經存在的檔案末尾
示例:hadoop fs -appendToFile ./hello.txt hdfs://hadoop-hello/hello.txt
- cat
功能:顯示檔案內容
示例:hadoop fs -cat /hello.txt
- tail
功能:顯示一個檔案的末尾
示例:hadoop fs -tail /weblog/access_log
- chgrp chmod chown
功能:linux檔案系統中的用法一樣,對檔案所屬許可權
hadoop fs -chomod 666 /hello.txt
- copyFromLocal
功能:從本地檔案系統中拷貝檔案到hdfs路徑中去
示例:hadoop fs -copyFromLocal ./hello.txt /aa
-copyToLocal
功能:從hdfs拷貝到本地
示例:hadoop fs -copyToLocal /aa/hello.txt
- cp
功能:從hdfs的一個路徑拷貝到hdfs的另一個路徑
示例:hadoop fs -cp /aa/hello.txt /bb/hello.txt
- mv
功能:在hdfs目錄中移動檔案
示例:hdfs fs -mv /aa/hello.txt /
- get
功能:等同於copyToLocal,就是從hdfs下載檔案到本地
示例:hadoop fs -get /aa/hello.txt
- getmerge
功能:合併下載多個檔案
示例:比如hdfs的目錄/aa/下由多個檔案:log.1 log.2… hadoop fs -getmerge /aa/log.* ./log.sum
- put
功能:等同於copyFromLocal
示例:hadoop fs -put /hello.txt /aa
- rm
功能:刪除檔案或資料夾
示例:hadoop fs -rm -r /aa/bb/
- rmdir
功能:刪除空目錄
示例:hadoop fs -mkdir /aa/bb/cc
- df
功能:統計檔案系統的可用空間資訊
示例:hadoop fs -df -h /
- du
功能:統計資料夾的大小資訊
示例:hadoop fs -du -s -h /aa/*
- count
功能:統計一個指定目錄下的檔案節點數量
示例:hadoop fs -count /aa
- setrep
功能:設定hdfs中檔案的副本數量
示例:hadoop fs -setrep 3 /aa/hello.txt (這裡設定的副本數只是記錄在namenode的元資料中,是否真的會有這麼多副本,還要看datanode的數量)