(要先看hdfs的ha配置再看这个 这个·有很多省略 上一篇说的比较详细)
官网配置网址 http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html
仍然使用notepad++的插件功能 连接hadoop01 然后找到usr下的local下的hadoop-2.7.1下的etc下的hadoop的yarn-site.xml 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> <!--是否启用yarn的HA--> <property> <name>yarn.resourcemanager.ha.enabled</name> <value>true</value> </property> <!--yarn的HA虚拟服务名--> <property> <name>yarn.resourcemanager.cluster-id</name> <value>qfyarn</value> </property> <!--yarn的HA虚拟服务名下的具体的rm--> <property> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property> <!--指定rm1的所启动的主机--> <property> <name>yarn.resourcemanager.hostname.rm1</name> <value>hadoop01</value> </property> <!--指定rm2的所启动的主机--> <property> <name>yarn.resourcemanager.hostname.rm2</name> <value>hadoop02</value> </property> <!--rm1的web ui的通信地址--> <property> <name>yarn.resourcemanager.webapp.address.rm1</name> <value>hadoop01:8088</value> </property> <!----> <property> <name>yarn.resourcemanager.webapp.address.rm2</name> <value>hadoop02:8088</value> </property> <!----> <property> <name>yarn.resourcemanager.zk-address</name> <value>hadoop01:2181,hadoop02:2181,hadoop03:2181</value> </property> </configuration>然后还要改一个文件 mapred-site.xml.template 将其改名为mapred-site.xml
然后打开我们备份的那个mapred-site.xml 复制其中一小段内容到我们正在配置的mapred-site.xml
<!--指定MapReduce的运行框架--> <property> <name>mapreduce.framework.name</name> <value>yarn</value> <final>true</final> </property>这样就行了 我们 接下来 远程发送这两个文件(在01下先进入hadoop-2.7.1)
scp -r ./etc/hadoop/mapred-site.xml ./etc/hadoop/yarn-site.xml hadoop02:/usr/local/hadoop-2.7.1/etc/hadoop/然后应该做ssh免登陆 因为配置hdfs的ha做过 所以我们就不用做了
然后直接启动
start-yarn.sh01jps一下 因为02没有启动ResourceManager 我们手动启动 02
03
然后我们看一下web ui http://192.168.37.111:8088/ 点击about 看状态是active 我们再看一下02的状态 是standby
我们测试一下上传下载文件 01下 写个文件里面随便加点东西 然后上传到hfds的根目录下
hdfs dfs -put /home/words /然后
yarn jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /words /out/00测试这个文件的单词数目统计 看看能不能用
结果出错了 原来是shuffle没配 找备份的yarn.site的这一段 配置到新的hadoop下的yarn.site 如图
<!--指定MapReduce的shuffle--> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property>这样的错误了话 需要重新scp分发这个文件到02 03 先关闭yarn
stop-yarn.sh然后进入hadoop-2.7.1目录 然后分发
scp ./etc/hadoop/yarn-site.xml hadoop02:/usr/local/hadoop-2.7.1/etc/hadoop/然后再次启动 启动之前 查看01 jps 02 还有ResourceManager 关闭这个进程服务 正式启动01下
start-yarn.sh然后在02下手动启动ResourceManger
yarn-daemon.sh start resourcemanager然后jps01 02 然后重新运行yarn jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /words /out/03 记得改下目录 不该就报已经存在的错误 我就报错了
这样就完了 然后查看内容hdfs dfs -cat /out/03/part-r-00000
最后测试是否是高可用 关闭active的rm 然后查看是否正常 杀死01的resourcemanager 然后01 02的web ui分别刷新下 01的已经访问不了了 02的状态改为active了 测试成功
然后再跑一边测试单词数的 记得改输出文件名 在01下跑就行 测试成功 等待跑完 查看 没问题 到此为止 yarn的高可用搭建完毕