day4_Yarn和Map/Reduce配置啟動(dòng)和原理講解
云計(jì)算:分布式計(jì)算,分布在多臺(tái)機(jī)器上同時(shí)運(yùn)行的運(yùn)算凿渊。
- 分布式計(jì)算原則:移動(dòng)計(jì)算阳似,而不是移動(dòng)數(shù)據(jù)
hadoop默認(rèn)包含了hdfs、yarn猾编、mapReduce三個(gè)組件
- yarn(Yet Another Resource Negotiater)是資源調(diào)度系統(tǒng)旗芬,yarn調(diào)配的是內(nèi)存和cpu舌胶,不參入計(jì)算。
- map/reduce是計(jì)算引擎
配置vim /usr/local/hadoop/etc/hadoop/mapred-site.xml
,指明mapreduce在那個(gè)框架上跑
- 只需namenode上配置
- 默認(rèn)情況下疮丛,/usr/local/hadoop/etc/hadoop/文件夾下只有
mapred-site.xml.template
文件幔嫂,我們要復(fù)制該文件,并命名為mapred-site.xml
cp mapred-site.xml.template mapred-site.xml
# 添加如下內(nèi)容
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
配置yarn:vim /usr/local/hadoop/etc/hadoop/yarn-site.xml
- resourceManager和dataManager都需要配置
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
啟動(dòng)yarn:start-yarn.sh
yarn與hdfs在邏輯上分離誊薄,各自啟動(dòng)各自的
已經(jīng)配置過slaves文件
jps
查看可以使用
yarn-daemon.sh
單獨(dú)啟動(dòng)ResourceManager和NodeManageryarn網(wǎng)頁訪問在:http:192.168.56.100:8088
運(yùn)行一個(gè)map/reduce示例程序
- 啟動(dòng)hdfs:
start-dfs.sh
- 上傳一個(gè)文件到hdfs的
/input
目錄上
hadoop fs -mkdir /input
hadoop fs -put ./input.txt /input
-
input.txt
內(nèi)容如下
hello java
hello java
hello c
hello c++
hello python
- 查找示例程序文件:
find /usr/local/hadoop -name *example*.jar
- 找到該jar包
/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar
- 找到該jar包
- 運(yùn)行示例程序:
hadoop jar xxx.jar wordcount /input/input.txt /output
- 即
hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input/input.txt /output
- 即
- 查看輸出內(nèi)容:
hadoop fs -text /output/part-r-00000
- 通過網(wǎng)頁來觀察job的運(yùn)行情況
經(jīng)驗(yàn):yarn-site
如果是集中啟動(dòng)的履恩,其實(shí)只需要在管理機(jī)上配置一份即可,但如果是單獨(dú)啟動(dòng)呢蔫,需要每臺(tái)機(jī)器一份似袁,在網(wǎng)頁上可以看到當(dāng)前機(jī)器的配置,已經(jīng)這個(gè)配置的來源咐刨。