【大數(shù)據(jù)學(xué)習(xí)篇3】HDFS命令操作與MR單詞統(tǒng)計
#在/目錄創(chuàng)建一個為test名字的文件夾
[hd@master bin]$ hdfs dfs -mkdir /test
#查看/目錄
[hd@master bin]$ hdfs dfs -ls?
Found 1 items
drwxr-xr-x? ?- hd supergroup? ? ? ? ? 0 2020-02-27 01:02 /test
#創(chuàng)建一個本地的txt文件
[hd@master ~]$ echo "abc123def456" > hello.txt?
#把創(chuàng)建的文件上傳到hdfs
[hd@master ~]$ hdfs dfs -put hello.txt? /?
#在hdfs查看上傳的文件
[hd@slave02 ~]$ hdfs dfs -cat /hello.txt
abc123def456
#下載hdfs文件到本地的linux當(dāng)前目錄
[hd@slave02 ~]$ ll
total 0
drwxrwxr-x. 4 hd hd 30 Feb 26 23:08 apps
#下載hdfs文件到當(dāng)前目錄
[hd@slave02 ~]$ hdfs dfs -get /hello.txt .
[hd@slave02 ~]$ ll
total 4
drwxrwxr-x. 4 hd hd 30 Feb 26 23:08 apps
-rw-r--r--. 1 hd hd 13 Feb 27 01:13 hello.txt
[hd@slave02 ~]$?
[hd@slave02 ~]$ cat hello.txt?
abc123def456

MapReduct執(zhí)行單詞統(tǒng)計的程序
#創(chuàng)建文件
[hd@master ~]$ vi words.txt
Hello World Bye World
Hello Hadoop Bye Hadoop
Bye Hadoop Hello Hadoop
#上傳文件
[hd@master ~]$ hdfs dfs -mkdir /word
[hd@master ~]$ hdfs dfs -put words.txt /word
#執(zhí)行單詞統(tǒng)計的樣例
[hd@master hadoop]$ hadoop jar /home/hd/apps/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.0.0.jar wordcount /word/words.txt /out