• hadoop记录篇4-mapreduce2(yarn)集群安装和ha高可用


    一。 yarn架构

        mapreduce从 0.2.3之后 进行了重构, 发布新的mapreduce 版本v2, 也可以称为 yarn 引入了资源调度的概念 之前的JobTracker 被拆分成了 Resouce Manager和ApplicationMaster

      结构上 yarn存在两种类型的节点 主节点称为Resouce Manager(RM) 从节点(执行任务)称为 Node Manager(NM)

      一个yarn应用中只有一个激活的Resouce Manager 每个应用(每个拆分的任务)都有一个ApplitionMaster (AM)所有被提交的job 都会经过 Resouce Manager进行分配  Application Master主要从 Resouce Manager中申请资源 同时监控 每个NodeManager运行任务的状态信息

       ResouceManager包含两个主要控件  Scheduler and ApplicationsManager.

       Scheduler用于分配有限资源给应用 只是调度资源不会监控 资源单位是 Container yarn提供了一些调度的类可供使用 比如CapacityScheduler和 FairScheduler

       ApplicationsManager 用于接收任务的提交 指定哪个NodeManager的ApplicationMaster执行任务 协商ApplicationMaster申请的第一个Container资源 同意后交给调度,

     提供失败后重启ApplicationMaster功能

       NodeManger是一个Container的代理 监控当前机器的cpu 内容 io 网络等 报告这些资源给Resouce Manager 方便统一管理

    原理图

         

    运行过程:

        1 启动后 每个NodeManager向ResouceManager汇报每个节点的网络 cpu 内存等资源 NodeManager进行汇总  RM的Scheduler 将所有资源

           分成多个Container

        2 客户端提交任务给ResourceManager的ApplicationManager  ApplicationManager调用任务拆分成多个 启用对应NodeManager的ApplicationMaster 调用Scheduler 分配 用于运行Containner ApplicationMaster开始执行任务  

        3 ApplicationMaster监控任务执行状态 并发送心跳给ResourceManager

      

    二 。yarn集群安装

      环境 使用之前  hadoop记录篇3-namenode水平拓展Federation+viewfs

    机器

    /etc/hosts    
    192.168.58.147 node1    
    192.168.58.149 node2    
    192.168.58.150 node3    
    192.168.58.151 node4    

    集群(clusterid:hadoop)

    namenode    
       node1  nameserviceid:node1    
       node2  nameserviceid:node2  
    secondarynode  
       node1  
       node2  
    DataNodes    
       node2    
       node3    
       node4    
          
    Resource Manager
      node1
    NodeManger
      node2
      node3
      node4  
    
    hdfs配置参考前面文章 

    进入etc/haddop中 将 mapred-site.xml.template重命名为 mapred-site.xml 添加如下内容

    <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
    </property>
    yarn-site.xml 添加内容

    <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
     <property>
            <name>yarn.resourcemanager.hostname</name>
            <value>node1</value>
        </property>
    以下关于yarn配置 都有默认值 给出意思

    yarn.resourcemanager.hostname 表示resourcemanager的主机名 
    yarn.resourcemanager.address  表示resourcemanger中applicationmanager对外接受提交任务的ip和端口 默认ip本机 端口 ${yarn.resourcemanager.hostname}:8032
    yarn.resourcemanager.scheduler.address 表示resoucemanager中Scheduler用于接受NodeManager汇报本地cpu 网络等资源的端口 默认 ${yarn.resourcemanager.hostname}:8030
    yarn.resourcemanager.resource-tracker.address 表示nodemanager上用于接受被切片的job的端口 默认 ${yarn.resourcemanager.hostname}:8031
    yarn.resourcemanager.webapp.address 用于查看所有提交任务信息的web界面 默认端口 ${yarn.resourcemanager.hostname}:8088
    yarn.resourcemanager.admin.address 管理员用于管理资源的端口 默认 ${yarn.resourcemanager.hostname}:8033
    yarn.resourcemanager.scheduler.class 调度使用的类 建议使用CapacityScheduler 或者FairScheduler  默认是org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler
    yarn.scheduler.minimum-allocation-mb 每个containner分配的最小内存 默认1024M
    yarn.scheduler.maximum-allocation-mb 每个container分配的最大内存 默认 8192M
    yarn.nodemanager.resource.memory-mb nodemanger可以使用最大的内存 默认 8192M

    NodeManager的所有节点部署的位置和datanode配置是一致的 都是在slaves文件中配置的

    启动yarn集群

    start-yarn.sh
    

    三。yarn高可用安装

      resourcemanager存在单点故障问题 提供一个standby的备机用于容)

    原理:


    yarn-site.xml配置(参考http://hadoop.apache.org/docs/r2.6.5/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html)

    <?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>
    
    <!-- Site specific YARN configuration properties -->
    <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
    <!--非高可用
    <property>
            <name>yarn.resourcemanager.hostname</name>
            <value>node1</value>
        </property>
    -->	
    
    <!--高可用-->	
    
    <property>
       <name>yarn.resourcemanager.ha.enabled</name>
       <value>true</value>
     </property>
     <!--yarn集群编号-->
     <property>
       <name>yarn.resourcemanager.cluster-id</name>
       <value>ha_resouce</value>
     </property>
      <!--高可用中 两个resourcemanager的id-->
     <property>
       <name>yarn.resourcemanager.ha.rm-ids</name>
       <value>rm1,rm2</value>
     </property>
      <!--编号为rm1的主机是node1-->
     <property>
       <name>yarn.resourcemanager.hostname.rm1</name>
       <value>node1</value>
     </property>
      <!--编号为rm2的主机是node2-->
     <property>
       <name>yarn.resourcemanager.hostname.rm2</name>
       <value>node2</value>
     </property>
      <!--配置用于调度的zk所在的服务器和ip  这个安装zk 我直接安装在window上-->
     <property>
       <name>yarn.resourcemanager.zk-address</name>
       <value>192.168.58.1:2181</value>
     </property> 
      <!--自动切换 设置为true-->
    <property>
    <name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
    <value>true</value>
    </property>
    
    	
    </configuration>

    node1上 执行 start-yarn.sh 不会自动启动node2上的resourcemanager
    node2 手工启动 yarn-daemon.sh start resourcemanager


    node1上查看rm1和rm2 哪个是active哪个是standby
    [root@node1 hadoop]# yarn rmadmin -getServiceState rm2
    standby
    [root@node1 hadoop]# yarn rmadmin -getServiceState rm1
    active

    尝试在node1上停止 resourcemanager 测试rm2是否自动切换为active

    [root@node1 hadoop]# yarn-daemon.sh stop resourcemanager
    stopping resourcemanager
    [root@node1 hadoop]# yarn rmadmin -getServiceState rm2  
    active
    


  • 相关阅读:
    优秀大整数
    洛谷—— P3908 异或之和
    洛谷—— P1869 愚蠢的组合数
    洛谷—— P1680 奇怪的分组
    洛谷—— P1609 最小回文数
    Something I like
    数学相关
    新博客测试中~
    P3369 【模板】普通平衡树
    2017 11.6 NOIP模拟赛
  • 原文地址:https://www.cnblogs.com/liaomin416100569/p/9331179.html
Copyright © 2020-2023  润新知