應(yīng)用場(chǎng)景:
1 計(jì)數(shù)和統(tǒng)計(jì)
2 整理
3 過(guò)濾
4 排序
1、Hadoop安裝
2仅颇、映射器(Mapper)
映射器的任務(wù)是將輸入轉(zhuǎn)換成一系列的鍵值對(duì)。比如在字計(jì)數(shù)器的情況下碘举,輸入是一系列的行忘瓦。我們按單詞將它們分開(kāi),把它們變成鍵值對(duì)(如key:word,value:1),看起來(lái)像這樣:
the 1
water 1
on 1
on 1
water 1
on 1
... 1
3殴俱、reducer
reducer的任務(wù)是檢索(排序)對(duì),迭代并轉(zhuǎn)換為所需輸出枚抵。 在單詞計(jì)數(shù)器的例子中线欲,取單詞數(shù)(值),并將它們相加得到一個(gè)單詞(鍵)及其最終計(jì)數(shù)汽摹。如下:
water 2
the 1
on 3
4李丰、基于單詞計(jì)數(shù)器的理解:
hadoop jar /usr/hadoop/2.5.1/libexec/lib/hadoop-streaming-2.5.1.jar \
-mapper "./mapper.php"http://將數(shù)據(jù)處理成鍵值對(duì)
-reducer "./reducer.php"http://將鍵值對(duì)歸類
-input "hello/mobydick.txt"http://將數(shù)據(jù)寫入文件
-output "hello/result"http://輸出統(tǒng)計(jì)結(jié)果寫入文件