1.配置mapred-site.xml(默認沒有mapred-site.xml文件,從mapred-site.xml.template文件複製一份,改名爲mapred-site.xml就可以)
2.配置yarn-site.xml
<?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>
<!-- 超時的週期 -->
<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.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.embedded</name>
<value>true</value>
</property>
<!-- 給yarn cluster 取個名字yarn-rm-cluster -->
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>yarn-rm-cluster</value>
</property>
<!-- 給ResourceManager 取個名字 rm1,rm2 -->
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<!-- 配置ResourceManager rm1 hostname -->
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>hadoop001</value>
</property>
<!-- 配置ResourceManager rm2 hostname -->
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>hadoop002</value>
</property>
<!-- 啓用resourcemanager 自動恢復 -->
<property>
<name>yarn.resourcemanager.recovery.enabled</name>
<value>true</value>
</property>
<!-- 配置Zookeeper地址 -->
<property>
<name>yarn.resourcemanager.zk.state-store.address</name>
<value>hadoop001:2181,hadoop002:2181,hadoop003:2181,hadoop004:2181,hadoop005:2181</value>
</property>
<!-- 配置Zookeeper地址 -->
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>hadoop001:2181,hadoop002:2181,hadoop003:2181,hadoop004:2181,hadoop005:2181</value>
</property>
<!-- rm1端口號 -->
<property>
<name>yarn.resourcemanager.address.rm1</name>
<value>hadoop001:8032</value>
</property>
<!-- rm1調度器的端口號 -->
<property>
<name>yarn.resourcemanager.scheduler.address.rm1</name>
<value>hadoop001:8034</value>
</property>
<!-- rm1 webapp端口號 -->
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>hadoop001:8088</value>
</property>
<!-- rm2端口號 -->
<property>
<name>yarn.resourcemanager.address.rm2</name>
<value>hadoop002:8032</value>
</property>
<!-- rm2調度器的端口號 -->
<property>
<name>yarn.resourcemanager.scheduler.address.rm2</name>
<value>hadoop002:8034</value>
</property>
<!-- rm2 webapp端口號 -->
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>hadoop002:8088</value>
</property>
<!-- 執行MapReduce需要配置的shuffle過程 -->
<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>
3.向其他節點同步yarn配置(deploy.sh etc/ /usr/hadoop/app/hadoop/ all)
在hadoop001節點上執行(sbin/start-yarn.sh)
在hadoop002節點上面執行(sbin/yarn-daemon.sh start resourcemanager)
訪問hadoop001的web頁面,如下
訪問hadoop002的web頁面,如下
6.查看ResourceManager狀態
如果上面執行沒有異常,說明YARN安裝成功