将每次Hadoop运行功能都放到HDFS上

1、开启日志聚集功能

[admin@hadoop13 hadoop-2.7.2]$ vim etc/hadoop/yarn-site.xml 

添加如下配置:

<!-- 日志聚集功能使能 -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<!-- 日志保留时间设置7天 -->
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>

2、关闭nodemanager 、resourcemanager和historymanager

[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh stop resourcemanager
[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh stop nodemanager
[admin@hadoop13 hadoop-2.7.2]$ sbin/mr-jobhistory-daemon.sh stop historyserver

3、启动nodemanager 、resourcemanager和historymanager

[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh start resourcemanager
[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh start nodemanager
[admin@hadoop13 hadoop-2.7.2]$ sbin/mr-jobhistory-daemon.sh start historyserver

5、删除hdfs上已经存在的hdfs文件

[admin@hadoop13 hadoop-2.7.2]$ hadoop fs -rm -R /user/admin/mapreduce/wordcount/output

6、执行wordcount程序

[admin@hadoop13 hadoop-2.7.2]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /user/admin/mapreduce/wordcount/input /user/admin/mapreduce/wordcount/output

7、查看日志

http://192.168.1.113:19888/jobhistory

二十九、日志的聚集_从零开始学大数据

二十九、日志的聚集_日志聚集_02

二十九、日志的聚集_大数据_03

8、停止服务

[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh stop nodemanager 
[admin@hadoop13 hadoop-2.7.2]$ sbin/yarn-daemon.sh stop resourcemanager 
[admin@hadoop13 hadoop-2.7.2]$ sbin/mr-jobhistory-daemon.sh stop historyserver 
[admin@hadoop13 hadoop-2.7.2]$ sbin/hadoop-daemon.sh stop datanode 
[admin@hadoop13 hadoop-2.7.2]$ sbin/hadoop-daemon.sh stop namenode