Hadoop基础(四十):HDFS HA 高可用(三)YARN-HA 配置

1 YARN-HA 工作机制

1. 官方文档:
http://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html
2. YARN-HA 工作机制,如图 3-23 所示

 

 

2 配置 YARN-HA 集群

1. 环境准备
(1)修改 IP
(2)修改主机名及主机名和 IP 地址的映射
(3)关闭防火墙
(4)ssh 免密登录
(5)安装 JDK,配置环境变量等
(6)配置 Zookeeper 集群
2. 规划集群
3. 具体配置
(1)yarn-site.xml
<configuration>

    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>

    <!--启用resourcemanager ha-->
    <property>
        <name>yarn.resourcemanager.ha.enabled</name>
        <value>true</value>
    </property>
 
    <!--声明两台resourcemanager的地址-->
    <property>
        <name>yarn.resourcemanager.cluster-id</name>
        <value>cluster-yarn1</value>
    </property>

    <property>
        <name>yarn.resourcemanager.ha.rm-ids</name>
        <value>rm1,rm2</value>
    </property>

    <property>
        <name>yarn.resourcemanager.hostname.rm1</name>
        <value>hadoop102</value>
    </property>

    <property>
        <name>yarn.resourcemanager.hostname.rm2</name>
        <value>hadoop103</value>
    </property>
 
    <!--指定zookeeper集群的地址--> 
    <property>
        <name>yarn.resourcemanager.zk-address</name>
        <value>hadoop102:2181,hadoop103:2181,hadoop104:2181</value>
    </property>

    <!--启用自动恢复--> 
    <property>
        <name>yarn.resourcemanager.recovery.enabled</name>
        <value>true</value>
    </property>
 
    <!--指定resourcemanager的状态信息存储在zookeeper集群--> 
    <property>
        <name>yarn.resourcemanager.store.class</name>     <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>

</configuration>
(2)同步更新其他节点的配置信息
 
4. 启动 hdfs
(1)在各个 JournalNode 节点上,输入以下命令启动 journalnode 服务:
sbin/hadoop-daemon.sh start journalnode
(2)在[nn1]上,对其进行格式化,并启动:
bin/hdfs namenode -format
sbin/hadoop-daemon.sh start namenode
(3)在[nn2]上,同步 nn1 的元数据信息: 
bin/hdfs namenode -bootstrapStandby
(4)启动[nn2]:
 
sbin/hadoop-daemon.sh start namenode
(5)启动所有 DataNode 
 
sbin/hadoop-daemons.sh start datanode
(6)将[nn1]切换为 Active 
 
bin/hdfs haadmin -transitionToActive nn1
5. 启动 YARN
(1)在 hadoop102 中执行:
sbin/start-yarn.sh
(2)在 hadoop103 中执行: 
 
sbin/yarn-daemon.sh start resourcemanager
(3)查看服务状态,如图 3-24 所示
bin/yarn rmadmin -getServiceState rm1

 

 

 

 

 

posted @ 2020-07-21 15:51  秋华  阅读(368)  评论(0编辑  收藏  举报