⼤数据实验总结(六)--搭建Mapreduce(YARN)环境,运⾏Wordcount⽰例搭建Mapreduce(YARN)环境,运⾏Wordcount⽰例
搭建Mapreduce(YARN)环境
修改l⽂件:
cd /usr/local/hadoop/etc/hadoop/
l
如图:
上海到安吉
具体内容:
<!-- Site specific YARN configuration properties -->
<configuration>
<property>
<name&sourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name&demanager.aux-rvices</name>
<value>mapreduce_shuffle</value>
</property>
大至<property>
<name&demanager.aux-rvices.mapreduce_shuffle.class </name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
其中名称sourcemanager.hostname指的是ResourceManager机器所在的节点位置;名称demanager.aux-rvices在hadoop2.2.0版本中是mapreduce_shuffle.
测试YARN环境
启动hdfs
start-dfs.sh
启动hdfs
Start-yarn.sh
使⽤浏览器打开页⾯:
master:8088/
或192.168.50.100:8088/
测试Mapreduce环境(运⾏Wordcount⽰例)
find /usr/local/hadoop -name *example*.jar
/
/查找⽰例程序,⽬录名需根据⾃⼰环境适当调整。
在HDFS上创建input⽬录
hdfs dfs -mkdir input
在HDFS上创建output⽬录
分数除以分数
hdfs dfs -mkdir output
创建运⾏⽰例⽂档并进⾏编写:
例:
helol
123
hello world
hello java
hello html
hello css
hello c
hello c#
hello world
hello css
hello c
纯牛奶洗脸hello c#
hello world
hello css
qq免费背景
hello css
hello css
hello c
hello c#
hello world
hello c
hello c#
hello world
hello c
hello c#
hello world
hello css
hello c
hello c#
hello world
hello css
hello c
将上传到HDFS中input⽬录下:
hdfs dfs - /input
洗涤读音
查看:
hdfs dfs -ls /input
运⾏Wordcount⽰例程序:
输⼊为:/ ,运⾏结果输出⽬录为: /output
hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount / /output
出现错误(FileAlreadyExistsException: Output directory hdfs://master:9000/output already exists):
会天大雨原因:
上次运⾏的输出⽬录也是output,没有进⾏删除。(好像每次运⾏的输出⽬录不能存在,运⾏过程中⾃动创建,若存在则运⾏失败,也有可能是我重复执⾏同⼀个⽂件的原因)
解决⽅法:
将/output⽬录删除:
hdfs dfs -rm -r /output
再次运⾏,成功:
四维怎么看男女查看运⾏结果:
hdfs dfs -text /output/part-r-00000
注意事项: