1. 本地建立文本文件
[root@s166 fantj]
[root@s166 fantj]
[root@s166 input]
[root@s166 input]
[root@s166 input]
[root@s166 input]
file1.txt file2.txt file3.txt
複製代碼
2. 將文件上傳到hadoop
[root@s166 input]
[root@s166 input]
Found 1 items
drwxr-xr-x - root supergroup 0 2018-07-27 07:51 /wordcount
[root@s166 input]
[root@s166 fantj]
download hadoop input jdk
[root@s166 fantj]
[root@s166 fantj]
Found 3 items
-rw-r--r-- 3 root supergroup 12 2018-07-27 07:52 /wordcount/file1.txt
-rw-r--r-- 3 root supergroup 13 2018-07-27 07:52 /wordcount/file2.txt
-rw-r--r-- 3 root supergroup 16 2018-07-27 07:52 /wordcount/file3.txt
複製代碼
3. 啓用hadoop自帶單詞統計進行處理
[root@s166 fantj]
[root@s166 hadoop]
common hdfs httpfs kms mapreduce tools yarn
[root@s166 hadoop]
[root@s166 mapreduce]
hadoop-mapreduce-client-app-2.7.0.jar hadoop-mapreduce-client-hs-plugins-2.7.0.jar hadoop-mapreduce-examples-2.7.0.jar
hadoop-mapreduce-client-common-2.7.0.jar hadoop-mapreduce-client-jobclient-2.7.0.jar lib
hadoop-mapreduce-client-core-2.7.0.jar hadoop-mapreduce-client-jobclient-2.7.0-tests.jar lib-examples
hadoop-mapreduce-client-hs-2.7.0.jar hadoop-mapreduce-client-shuffle-2.7.0.jar sources
[root@s166 mapreduce]
複製代碼
查看結果
[root@s166 mapreduce]
Found 2 items
-rw-r--r-- 3 root supergroup 0 2018-07-27 07:55 /print/_SUCCESS
-rw-r--r-- 3 root supergroup 37 2018-07-27 07:55 /print/part-r-00000
[root@s166 mapreduce]
fantj 1
hadoop 1
hello 3
mapreduce 1
複製代碼