1.hadoop集群的啟動
cd $HADOOP_HOME //進入hadoop安裝目錄
sbin/start-dfs.sh //啟動hdfs
sbin/start-yarn.sh //啟動yarn
(或start-all.sh)
集群關閉:
cd $HADOOP_HOME //進入hadoop安裝目錄
sbin/stop-yarn.sh //啟動hdfs
sbin/stop-dfs.sh //啟動yarn
(或stop-all.sh)
集群的架構:
master節點的ip是192.168.26.110
查看集群的運行狀態:
查看集群的目錄結構:
http://192.168.56.110:50070/explorer.html
2:查看、創建、刪除目錄:
[root@master conf]# hadoop fs -ls / ##查看根目錄
Hadoop fs -mkdir /test ##創建目錄
Hadoop fs -mkdir -p /test/a/b ##創建多級文件
刪除文件和目錄
Hadoop fs -rm /hello.txt ##刪除文件
Hadoop fs -rm -R /test ##遞歸刪除文件夾
4:上傳文件
方法1:hadoop fs -put localfile /user/hadoop/hadoopfile
案例: hadoop fs -put word.txt /user/root/word1.txt
方法2:Usage: hadoop fs -copyFromLocal <localsrc> URI
案例:hadoop fs –copyFromLocal word.txt /user/root
方法3:Usage: hadoop fs -moveFromLocal <localsrc> <dst>
案例:hadoop fs -moveFromLocal word.txt /user/root/word2.txt
5:下載文件
方法1:hadoop fs -get /user/hadoop/file localfile
案例:hadoop fs -get /user/root/word1.txt .
方法2:Usage: hadoop fs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
案例:hadoop fs –copyToLocal /user/root/word.txt . ##.下載到當前目錄
方法3:Usage: hadoop fs -moveToLocal [-crc] <src> <dst>
案例:hadoop fs –moveToLocal /user/root/word2.txt .
Displays a “Not implemented yet” message.
6:查看內容
hadoop fs -cat hdfs://nn1.example.com/file1
案例:hadoop fs -cat /user/root/word.txt
hadoop fs -tail pathname
案例:hadoop fs -tail /user/root/word2.txt
7:刪除文件
hadoop fs -rm hdfs://nn.example.com/file /user/hadoop/emptydir
案例:hadoop fs –rm /user/root/word2.txt
