Apache Hadoop 2.9.2 的YARN High Available 模式部署

                                       作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.环境准备

1>.官方文档(http://hadoop.apache.org/docs/r2.9.2/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html

2>.实验环境

  环境在上一篇博客基础之上,参考链接:https://www.cnblogs.com/yinzhengjie/p/10720586.html

二.修改核心配置

1>.修改yarn-site.xml

[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9./etc/hadoop/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>yinzhengjie-yarn</value>
</property> <property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>resourcemanager1,resourcemanager2</value>
</property> <property>
<name>yarn.resourcemanager.hostname.resourcemanager1</name>
<value>node101.yinzhengjie.org.cn</value>
</property> <property>
<name>yarn.resourcemanager.hostname.resourcemanager2</name>
<value>node103.yinzhengjie.org.cn</value>
</property> <property>
<name>yarn.resourcemanager.webapp.address.resourcemanager1</name>
<value>node101.yinzhengjie.org.cn:</value>
</property> <property>
<name>yarn.resourcemanager.webapp.address.resourcemanager2</name>
<value>node103.yinzhengjie.org.cn:</value>
</property> <!--指定zookeeper集群的地址-->
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>node101.yinzhengjie.org.cn:,node102.yinzhengjie.org.cn:,node101.yinzhengjie.org.cn:</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>
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml

2>.将修改的配置文件同步到其他节点中

[root@node101.yinzhengjie.org.cn ~]# scp /yinzhengjie/softwares/hadoop-2.9./etc/hadoop/yarn-site.xml  node102.yinzhengjie.org.cn:/yinzhengjie/softwares/hadoop-2.9./etc/hadoop/
yarn-site.xml % .8MB/s :
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# scp /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml node102.yinzhengjie.org.cn:/yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/

[root@node101.yinzhengjie.org.cn ~]# scp /yinzhengjie/softwares/hadoop-2.9./etc/hadoop/yarn-site.xml  node103.yinzhengjie.org.cn:/yinzhengjie/softwares/hadoop-2.9./etc/hadoop/
yarn-site.xml % .0MB/s :
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# scp /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml node103.yinzhengjie.org.cn:/yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/

3>.启动hdfs集群

[root@node101.yinzhengjie.org.cn ~]# start-dfs.sh
Starting namenodes on [node101.yinzhengjie.org.cn node103.yinzhengjie.org.cn]
node101.yinzhengjie.org.cn: starting namenode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-namenode-node101.yinzhengjie.org.cn.out
node103.yinzhengjie.org.cn: starting namenode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-namenode-node103.yinzhengjie.org.cn.out
node103.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-datanode-node103.yinzhengjie.org.cn.out
node102.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-datanode-node102.yinzhengjie.org.cn.out
node101.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-datanode-node101.yinzhengjie.org.cn.out
Starting journal nodes [node103.yinzhengjie.org.cn node102.yinzhengjie.org.cn node101.yinzhengjie.org.cn]
node103.yinzhengjie.org.cn: starting journalnode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-journalnode-node103.yinzhengjie.org.cn.out
node102.yinzhengjie.org.cn: starting journalnode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-journalnode-node102.yinzhengjie.org.cn.out
node101.yinzhengjie.org.cn: starting journalnode, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-journalnode-node101.yinzhengjie.org.cn.out
Starting ZK Failover Controllers on NN hosts [node101.yinzhengjie.org.cn node103.yinzhengjie.org.cn]
node101.yinzhengjie.org.cn: starting zkfc, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-zkfc-node101.yinzhengjie.org.cn.out
node103.yinzhengjie.org.cn: starting zkfc, logging to /yinzhengjie/softwares/hadoop-2.9./logs/hadoop-root-zkfc-node103.yinzhengjie.org.cn.out
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs haadmin -getServiceState namenode1            #查看当前节点的状态!很显然,和下面的Web UI展示的结果一致!
active
[root@node101.yinzhengjie.org.cn ~]#

4>.启动yarn集群

[root@node101.yinzhengjie.org.cn ~]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-resourcemanager-node101.yinzhengjie.org.cn.out
node102.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node102.yinzhengjie.org.cn.out
node103.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node103.yinzhengjie.org.cn.out
node101.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node101.yinzhengjie.org.cn.out
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# start-yarn.sh                        #在resourcemanager1节点上启动YARN

[root@node101.yinzhengjie.org.cn ~]# jps
ZooKeeperMain
Jps
QuorumPeerMain
DFSZKFailoverController
JournalNode
NameNode
NodeManager
ResourceManager
DataNode
[root@node101.yinzhengjie.org.cn ~]#

[root@node101.yinzhengjie.org.cn ~]# jps

[root@node103.yinzhengjie.org.cn ~]# yarn-daemon.sh start resourcemanager
starting resourcemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-resourcemanager-node103.yinzhengjie.org.cn.out
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# jps
Jps
ResourceManager
JournalNode
NodeManager
QuorumPeerMain
NameNode
DFSZKFailoverController
DataNode
[root@node103.yinzhengjie.org.cn ~]#

[root@node103.yinzhengjie.org.cn ~]# yarn-daemon.sh start resourcemanager          #在resourcemanager2节点上启动rm进程

[root@node103.yinzhengjie.org.cn ~]# jps
ResourceManager
JournalNode
NodeManager
QuorumPeerMain
NameNode
DFSZKFailoverController
Jps
DataNode
[root@node103.yinzhengjie.org.cn ~]#

[root@node103.yinzhengjie.org.cn ~]# jps

[root@node103.yinzhengjie.org.cn ~]# yarn rmadmin -getServiceState resourcemanager1        #很显然,我们先启动的是resourcemanager1节点,因此它优先被选为Active状态!
active
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# yarn rmadmin -getServiceState resourcemanager2
standby
[root@node103.yinzhengjie.org.cn ~]#

三.验证YARN的高可用性

1>.将resourcemanager1节点进程杀掉,查看服务是否可以正常提供服务

[root@node101.yinzhengjie.org.cn ~]# jps
ZooKeeperMain
QuorumPeerMain
DFSZKFailoverController
JournalNode
NameNode
NodeManager
ResourceManager
DataNode
Jps
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# kill - `jps | grep ResourceManager | awk '{print $1}' `
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# jps
ZooKeeperMain
QuorumPeerMain
Jps
DFSZKFailoverController
JournalNode
NameNode
NodeManager
DataNode
[root@node101.yinzhengjie.org.cn ~]#  

2>.启动yarn集群后,注意观察zookeeper集群中生成的目录结构的变化哟!

[root@node101.yinzhengjie.org.cn ~]# zkCli.sh -server node103.yinzhengjie.org.cn:
Connecting to node103.yinzhengjie.org.cn:
-- ::, [myid:] - INFO [main:Environment@] - Client environment:zookeeper.version=3.4.-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on // : GMT
-- ::, [myid:] - INFO [main:Environment@] - Client environment:host.name=node101.yinzhengjie.org.cn
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.version=1.8.0_201
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.vendor=Oracle Corporation
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.home=/usr/lib/jvm/java-1.8.-openjdk-1.8.0.201.b09-.el7_6.x86_64/jre
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.class.path=/yinzhengjie/softwares/zookeeper-3.4./bin/../zookeeper-server/target/classes:/yinzhengjie/softwares/zookeeper-3.4./bin/../build/classes:/yinzhengjie/softwares/zookeeper-3.4./bin/../zookeeper-server/target/lib/*.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../build/lib/*.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/slf4j-log4j12-1.7.25.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/slf4j-api-1.7.25.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/netty-3.10.6.Final.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/log4j-1.2.17.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/jline-0.9.94.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../lib/audience-annotations-0.5.0.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../zookeeper-3.4.14.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../zookeeper-server/src/main/resources/lib/*.jar:/yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf:
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-957.el7.x86_64
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2019-04-19 10:22:52,912 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/root
2019-04-19 10:22:52,913 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=node103.yinzhengjie.org.cn:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5ce65a89
Welcome to ZooKeeper!
2019-04-19 10:22:52,938 [myid:] - INFO [main-SendThread(node103.yinzhengjie.org.cn:2181):ClientCnxn$SendThread@1025] - Opening socket connection to server node103.yinzhengjie.org.cn/172.30.1.103:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2019-04-19 10:22:52,998 [myid:] - INFO [main-SendThread(node103.yinzhengjie.org.cn:2181):ClientCnxn$SendThread@879] - Socket connection established to node103.yinzhengjie.org.cn/172.30.1.103:2181, initiating session
[zk: node103.yinzhengjie.org.cn:2181(CONNECTING) 0] 2019-04-19 10:22:53,026 [myid:] - INFO [main-SendThread(node103.yinzhengjie.org.cn:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server node103.yinzhengjie.org.cn/172.30.1.103:2181, sessionid = 0x6700035fda3a0000, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 0] ls /
[zookeeper,hadoop-ha]
[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 1]
[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 1] ls /
[zookeeper, yarn-leader-election, hadoop-ha, rmstore]
[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 2]
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ] get /yarn-leader-election

cZxid = 0x300000008
ctime = Fri Apr :: CST
mZxid = 0x300000008
mtime = Fri Apr :: CST
pZxid = 0x300000009
cversion =
dataVersion =
aclVersion =
ephemeralOwner = 0x0
dataLength =
numChildren =
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ]

[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 2] get /yarn-leader-election

[zk: node103.yinzhengjie.org.cn:(CONNECTED) ] ls /yarn-leader-election
[yinzhengjie-yarn]
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ]

[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 3] ls /yarn-leader-election

[zk: node103.yinzhengjie.org.cn:(CONNECTED) ] ls /yarn-leader-election/yinzhengjie-yarn
[ActiveBreadCrumb, ActiveStandbyElectorLock]
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ]

[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 4] ls /yarn-leader-election/yinzhengjie-yarn

[zk: node103.yinzhengjie.org.cn:(CONNECTED) ] get /yarn-leader-election/yinzhengjie-yarn/ActiveBreadCrumb       

yinzhengjie-yarnresourcemanager2
cZxid = 0x30000000b
ctime = Fri Apr :: CST
mZxid = 0x30000002c
mtime = Fri Apr :: CST
pZxid = 0x30000000b
cversion =
dataVersion =
aclVersion =
ephemeralOwner = 0x0
dataLength =
numChildren =
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ]

[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 7] get /yarn-leader-election/yinzhengjie-yarn/ActiveBreadCrumb

[zk: node103.yinzhengjie.org.cn:(CONNECTED) ] get /yarn-leader-election/yinzhengjie-yarn/ActiveStandbyElectorLock

yinzhengjie-yarnresourcemanager2
cZxid = 0x30000002b
ctime = Fri Apr :: CST
mZxid = 0x30000002b
mtime = Fri Apr :: CST
pZxid = 0x30000002b
cversion =
dataVersion =
aclVersion =
ephemeralOwner = 0x660003eeeeb10001
dataLength =
numChildren =
[zk: node103.yinzhengjie.org.cn:(CONNECTED) ]

[zk: node103.yinzhengjie.org.cn:2181(CONNECTED) 8] get /yarn-leader-election/yinzhengjie-yarn/ActiveStandbyElectorLock

随机推荐

  1. GroupData群数据库的还原与优化

    一.背景 这个数据库的数据文件mdf大概有83G左右,当还原数据库之后感觉可以做很多性能方面上的调优,合并数据后mdf数据文件大概有59G左右,行压缩后mdf数据文件大概有39G左右,页压缩后mdf数 ...

  2. PHP防止跨域提交表单

    在提交的服务段的数据进行验证.   $servername=$_SERVER['SERVER_NAME'];//当前运行脚本所在服务器主机的名字.  $sub_from=$_SERVER[" ...

  3. vs2013的安装以及单元测试

    一.安装过程 1.下载vs2013安装包,打开进行安装.安装过程时间有点长,大概用了一个小时. 2.安装完成.需要登录,可以选择以后再说. 3.选择颜色主题. 4.打开vs2013的界面. 5.添加密 ...

  4. kubernetes学习笔记1

    安装篇 Downloading Kubernetes You can either build a release from sources or download a pre-built relea ...

  5. ubuntu 14.04 64位系统编译RT288x_SDK

    sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sha ...

  6. ManagementFactory (二) getMemoryMXBean

    MemoryMXBean package cn.zno.outofmomery; import java.lang.management.ManagementFactory; import java. ...

  7. mysql查询一天,查询一周,查询一个月的数据【转】

    转自:http://www.cnblogs.com/likwo/archive/2010/04/16/1713282.html 查询一天: select * from table where to_d ...

  8. java Serializable和Externalizable序列化反序列化详解--转

    一.什么是序列化? “对象序列化”(Object Serialization)是 Java1.1就开始有的特性. 简单地说,就是可以将一个对象(标志对象的类型)及其状态转换为字节码,保存起来(可以保存 ...

  9. QT实现窗口缩放打开与关闭(重叠窗口,太有意思了)

    基本思想:假设A为主窗口,B为子窗口.A打开或关闭时,先对A窗口进行截图,然后将图片部满整个B窗口的,在paintEvent里面进行动态缩放或放大画图.最后使用动画,将B窗口以动画的形式打开或关闭,动 ...

  10. Day-1:初识开发板与基础知识

    买的这款51,ARM,AVR三合一的单片机,也不知道后面具体使用会不会有问题,先玩玩看吧. ------------------------------------------------------ ...