Hadoop日志管理在Ubuntu上的操作如下:
查看日志路徑
$HADOOP_HOME/logs(如/usr/local/hadoop/logs)。hadoop-env.sh中設置HADOOP_LOG_DIR,或在log4j.properties中配置具體組件日志路徑。查看日志內容
tail -f hadoop-<組件>-<主機名>.log(如hadoop-hdfs-namenode-hadoop01.log)。grep "錯誤關鍵詞" hadoop-<組件>.log。配置日志級別
log4j.properties文件(位于$HADOOP_HOME/etc/hadoop),修改log4j.rootLogger或特定包的日志級別(如DEBUG、ERROR)。$HADOOP_HOME/sbin/stop-all.sh && $HADOOP_HOME/sbin/start-all.sh。日志歸檔與清理
hadoop archive -archiveName test.har -p /input /outputdir。yarn-site.xml中配置yarn.log-aggregation.retain-seconds)自動清理舊日志。集中管理與分析
yarn-site.xml中啟用yarn.log-aggregation-enable=true,并指定聚合服務器。參考來源: