1.问题:Hadoop任务日志查看报错
1.1 页面日志查看报错
Failed while trying to construct the redirect url to the log server. Log Server url may not be configured
java.lang.Exception: Unknown container. Container either has not started or has already completed or doesn't belong to this node at all.
1.2 命令行查看日志报错
[root@lee000 spark-2.4.5-bin-2.6.0-cdh5.15.1]# yarn logs -applicationId application_1587435804451_0002
20/04/21 13:48:33 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
20/04/21 13:48:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
/tmp/logs/root/logs/application_1587435804451_0002 does not exist.
Log aggregation has not completed or is not enabled.
2.解决方案:
以上两种日志查看报错都可以用该方式解决
1)在"$HADOOP_HOME/etc/hadoop/mapred-site.xml"
文件中配置Jobhistory历史服务器
<configuration>
<property>
<name>mapreduce.jobhistory.address</name>
<value>lee000:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>lee000:19888</value>
</property>
</configuration>
2)在"$HADOOP_HOME/etc/hadoop/yarn-site.xml"
文件中配置Jobhistory历史服务器日志存储路径等
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<property>
<name>yarn.nodemanager.log-aggregation.roll-monitoring-interval-seconds</name>
<value>3600</value>
</property>
<property>
<name>yarn.nodemanager.remote-app-log-dir</name>
<value>/tmp/logs</value>
</property>
<property>
<name>yarn.log.server.url</name>
<value>http://lee000:19888/jobhistory/logs/</value>
</property>
3)在"$HADOOP_HOME/sbin"
中启动历史服务
./mr-jobhistory-daemon.sh start historyserver
重新执行任务后查看日志,如果还是不行,重启下YARN服务即可。