问题:
一开始job history是正常的,配置了日志的聚集以后不管做什么任务都不显示任务,hdfs是正常运行,而且根据配置步骤都重启过了。
下面先po出日志聚集的操作步骤,再讲问题
1.配置yarn-site.xml
cd $HADOOP_HOME/etc/hadoop
vim yarn-site.xml
添加如下代码
<!-- 开启日志聚集功能 -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<!-- 设置日志聚集服务器地址 -->
<property>
<name>yarn.log.server.url</name>
<value>http://hadoop102:19888/jobhistory/logs</value>
</property>
<!-- 设置日志保留时间为7天 -->
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>
2.分发配置
xsync $HADOOP_HOME/etc/hadoop/yarn-site.xml
3.关闭NodeManager 、ResourceManager和HistoryServer
sbin/stop-yarn.sh
mapred --daemon stop historyserver
4.启动NodeManager 、ResourceManage和HistoryServer
start-yarn.sh
mapred --daemon start historyserver
到这里都没有错,找了半天发现是前面配置的mapred-site.xml出错了,就是如果设置日志聚集的话,前面配置的mapred-site也需要修改一下配置。
如下:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
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.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<!-- 指定 MapReduce 程序运行在 Yarn 上,表示MapReduce使用yarn框架 -->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<!-- 开启MapReduce小任务模式 -->
<property>
<name>mapreduce.job.ubertask.enable</name>
<value>true</value>
</property>
<!-- 历史服务器端地址 -->
<property>
<name>mapreduce.jobhistory.address</name>
<value>hadoop102:10020</value>
</property>
<!-- 历史服务器web端地址 -->
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>hadoop102:19888</value>
</property>
</configuration>
yarn框架没有配置
造成的结果:
修改以后在分发一下,重新启动就好了,运行命令也有记录了
hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount /input /output
如图:
这样就改好了,出现类似问题的话,大部分就是mapred-site和yarn-site这两个文件没有配置好,就可以多检查几遍看看。
刚刚发现这个错误是源于我上一篇博文的修改错误的结果,但是很奇怪的是改回来再运行wordcount没有卡住了。