<?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.resourcemanager.ha.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property> <property> <name>yarn.resourcemanager.hostname.rm1</name> <value>rm1</value> </property> <property> <name>yarn.resourcemanager.hostname.rm2</name> <value>rm2</value> </property> <property> <name>yarn.resourcemanager.recovery.enabled</name> <value>true</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>zk1:2181,zk2:2181,zk3:2181</value> </property> <property> <name>yarn.resourcemanager.ha.id</name> <value>rm1</value> <description>每个rm节点分别配置。例如: rm1上配置为rm1, rm2上配置rm2</description> </property> <property> <name>yarn.resourcemanager.cluster-id</name> <value>hbasecluster</value> </property> <property> <name>yarn.resourcemanager.address.rm1</name> <value>rm1:8080</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm1</name> <value>rm1:8081</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm1</name> <value>rm1:8082</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm1</name> <value>rm1:23141</value> </property> <property> <name>yarn.resourcemanager.ha.admin.address.rm1</name> <value>rm1:23142</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm1</name> <value>rm1:23188</value> </property> <property> <name>yarn.resourcemanager.address.rm2</name> <value>rm2:8080</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm2</name> <value>rm2:8081</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm2</name> <value>rm2:8082</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm2</name> <value>rm2:23141</value> </property> <property> <name>yarn.resourcemanager.ha.admin.address.rm2</name> <value>rm2:23142</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm2</name> <value>rm2:23188</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> </configuration>
1, 其中需要注意的是yarn.resourcemanager.ha.id是对于每个rm节点单独配置的
2,配置后,首先使用前台方式启动查看是否配置正确
yarn resourcemanager
3,没问题后使用服务启动命令,注意每个rm节点都需要启动
yarn-daemon.sh start resourcemanager
4,验证:正常情况下,rm1(ip=103)节点是active节点,rm2(ip=104)节点为备份节点
看图,这是正常启动结果:
杀掉rm1上的进程,并重新启动,此时再看:
发现rm2已经成为活动节点。如果杀掉rm2上的进程并重新启动,rm1就会切换回active节点,而rm2切换回standby状态。