经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 大数据/云/AI » Hadoop » 查看文章
3.Hadoop测试Yarn和MapReduce
来源:cnblogs  作者:零度微笑  时间:2018/10/19 9:07:31  对本文有异议

Hadoop测试Yarn和MapReduce

1.配置Yarn

(1)配置ResourceManager

生产环境中,一般是重开一台机器作为ResourceManager,这里我们以Master机器代替。

修改yarn-site.xml:

  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License. See accompanying LICENSE file.
  12. -->
  13. <configuration>
  14. <property>
  15. <name>yarn.resourcemanager.hostname</name>
  16. <value>master</value>
  17. </property>
  18. <property>
  19. <name>yarn.nodemanager.aux-services</name>
  20. <value>mapreduce_shuffle</value>
  21. </property>
  22. <property>
  23. <name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
  24. <value>org.apache.hadoop.mapred.ShuffleHandler</value>
  25. </property>
  26. <!-- Site specific YARN configuration properties -->
  27. </configuration>

(2)配置NodeManager

NodeManager作为DataNode所在机器的资源管理程序,一般情况下直接放在DataNode所在节点。
修改yarn-site.xml:

  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License. See accompanying LICENSE file.
  12. -->
  13. <configuration>
  14. <property>
  15. <name>yarn.resourcemanager.hostname</name>
  16. <value>master</value>
  17. </property>
  18. <property>
  19. <name>yarn.nodemanager.aux-services</name>
  20. <value>mapreduce_shuffle</value>
  21. </property>
  22. <property>
  23. <name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
  24. <value>org.apache.hadoop.mapred.ShuffleHandler</value>
  25. </property>
  26. <!-- Site specific YARN configuration properties -->
  27. </configuration>

(3)启动yarn

在ResourceManager所在机器上:

start-yarn.sh

2.配置MapReduce

copy一份maper-site.xml.template作为maper-site.xml:

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <!--
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License. See accompanying LICENSE file.
  13. -->
  14. <!-- Put site-specific property overrides in this file. -->
  15. <configuration>
  16. <property>
  17. <name>mapreduce.framework.name</name>
  18. <value>yarn</value>
  19. </property>
  20. </configuration>

3.测试WordCount实例

(1)上传计算使用文件hello.txt

  1. hello xm
  2. hello sir
  3. java c
  4. python vb
  5. java c++
  6. go php
  7. erlang java

(2)输入测试命令

hadoop jar hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input/hello.txt /output

(3)查看测试结果

hadoop fs -ls /output

结果:

  1. Found 2 items
  2. -rw-r--r-- 3 root supergroup 0 2018-10-18 15:19 /output/_SUCCESS
  3. -rw-r--r-- 3 root supergroup 70 2018-10-18 15:19 /output/part-r-00000

hadoop fs -text /output/part-r-00000

结果:

  1. c 1
  2. c++ 1
  3. erlang 1
  4. go 1
  5. hello 2
  6. java 3
  7. php 1
  8. python 1
  9. sir 1
  10. vb 1
  11. xm 1

4.web查看测试结果

(1)HDFS:master:50070

(2)Yarn:master:8088

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号