zoukankan      html  css  js  c++  java
  • 3.Hadoop测试Yarn和MapReduce

    Hadoop测试Yarn和MapReduce

    1.配置Yarn

    (1)配置ResourceManager

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

    修改yarn-site.xml:

    <?xml version="1.0"?>
    <!--
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License. See accompanying LICENSE file.
    -->
    <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>
    <!-- Site specific YARN configuration properties -->
    
    </configuration>
    
    

    (2)配置NodeManager

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

    <?xml version="1.0"?>
    <!--
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
    
        http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License. See accompanying LICENSE file.
    -->
    <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>
    <!-- Site specific YARN configuration properties -->
    
    </configuration>
    
    

    (3)启动yarn

    在ResourceManager所在机器上:

    start-yarn.sh

    2.配置MapReduce

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

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

    3.测试WordCount实例

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

    hello xm
    hello sir
    java c
    python vb
    java c++
    go php
    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

    结果:

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

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

    结果:

    c	1
    c++	1
    erlang	1
    go	1
    hello	2
    java	3
    php	1
    python	1
    sir	1
    vb	1
    xm	1
    

    4.web查看测试结果

    (1)HDFS:master:50070

    (2)Yarn:master:8088

  • 相关阅读:
    oracle 静默安装
    浅析hybrid模式下地支付宝钱包和微信
    LeetCode96_Unique Binary Search Trees(求1到n这些节点能够组成多少种不同的二叉查找树) Java题解
    hdu 5411 CRB and Puzzle 矩阵高速幂
    Hadoop作业性能指标及參数调优实例 (三)Hadoop作业性能參数调优方法
    实现Android4.4系统设置分页滑动浏览功能
    oracle 数据库中数据导出到excel
    Nginx配置upstream实现负载均衡
    公司须要内部的地图服务,准备自己去开发可是成本太高,如今有没有专门为企业提供GIS地图开发的产品呀?大概价格多少?
    图片在内存中的占用的空间大小
  • 原文地址:https://www.cnblogs.com/TimerHotel/p/hadoop03.html
Copyright © 2011-2022 走看看