1. 环境准备
安装好hadoop-2.7.4版本高可用集群
安装好zookeeper-3.4.10版本集群
2.配置文件
需要修改yarn-site文件,ha id 是否需要根据不同机器改变尚未明确。
<configuration>
<property>
<name>yarn.resourcemanager.connect.retry-interval.ms</name>
<value>2000</value>
</property>
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>10.0.33.222:2181,10.0.33.223:2181,10.0.33.224:2181</value>
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>10.0.33.222</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>10.0.33.223</value>
</property>
<property>
<name>yarn.resourcemanager.ha.id</name>
<value>rm1</value>
</property>
<property>
<name>yarn.resourcemanager.recovery.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.zk-state-store.address</name>
<value>10.0.33.222:2181,10.0.33.223:2181,10.0.33.224:2181</value>
</property>
<property>
<name>yarn.resourcemanager.store.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>10.0.33.222:2181,10.0.33.223:2181,10.0.33.224:2181</value>
</property>
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>gagcluster-yarn</value>
</property>
<property>
<name>yarn.app.mapreduce.am.scheduler.connection.wait.interval-ms</name>
<value>5000</value>
</property>
<property>
<name>yarn.resourcemanager.address.rm1</name>
<value>10.0.33.222:8132</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address.rm1</name>
<value>10.0.33.222:8130</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>10.0.33.222:8088</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address.rm1</name>
<value>10.0.33.222:8131</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address.rm1</name>
<value>10.0.33.222:8033</value>
</property>
<property>
<name>yarn.resourcemanager.ha.admin.address.rm1</name>
<value>10.0.33.222:23142</value>
</property>
<property>
<name>yarn.resourcemanager.address.rm2</name>
value>10.0.33.223:8132</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address.rm2</name>
<value>10.0.33.223:8130</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>10.0.33.223:8088</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address.rm2</name>
<value>10.0.33.223:8131</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address.rm2</name>
<value>10.0.33.223:8033</value>
</property>
<property>
<name>yarn.resourcemanager.ha.admin.address.rm2</name>
<value>10.0.33.223:23142</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
<name>yarn.nodemanager.local-dirs</name>
<value>/part1/tomdir/yarn/local</value>
</property>
<property>
<name>yarn.nodemanager.log-dirs</name>
<value>/part1/tomdir/yarn/log</value>
</property>
<property>
<name>mapreduce.shuffle.port</name>
<value>23080</value>
</property>
<property>
<name>yarn.client.failover-proxy-provider</name>
<value>org.apache.hadoop.yarn.client.ConfiguredRMFailoverProxyProvider</value>
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.zk-base-path</name>
<value>/yarn-leader-election</value>
</property>
</configuration>
3.启动
在rm1机器上执行start-yarn.sh 命令
在rm2机器上执行yarn-daemon.sh start resourcemanager (不同于hadoop高可用,需要手动启动备用resource manager)
4.测试
打开yarn web控制台,查看rm1是否在active状态,rm2是否在standby状态。
kill掉rm1机器上resource manager,查看rm2是都在active状态。
执行如下命令,在web控制端查看job运行状态。
hadoop jar /opt/hadoop-mapreduce-examples-2.7.4.jar wordcount /user/root/ds.txt /user/root/ds_out3