在spark on yarn運作中,有時會發現spark程式運作完畢後,spark的運作界面沒有資訊,或者找不到相關的運作資訊了,經仔細檢視NodeManager UI
,出現如下資訊:
Log Aggregation Status TIME_OUT
原來NodeManager可以在應用結束後将日志安全地移動到分布式檔案系統HDFS,當應用(application)結束時,使用者能通過 YARN 的指令行工具、網頁端或者HDFS中來檢視這些日志
當打開yarn.log-aggregation-enable為true時,會啟用聚合,如果為false,NodeManager會把日志存儲在節點本地(${yarn.nodemanager.log-dirs}/application_${appid} )下
日志聚合的相關配置:
yarn.nodemanager.remote-app-log-dir: 這是 NodeManager将日志聚合後存放在HDFS 上的位址.
yarn.nodemanager.remote-app-log-dir-suffix: 日志目錄會這樣建立 {yarn.nodemanager.remote-app-log-dir}/${user}/{thisParam}
yarn.log-aggregation.retain-seconds: 聚合後的日志檔案在多久後被删除, 配置成 -1 或者一個負值不會删除
yarn.log-aggregation.retain-check-interval-seconds: 多長時間去檢查一次哪些聚合日志需要删除.
yarn.log.server.url: 應用結束後NodeManager會将網頁通路自動跳轉到聚合日志的位址, 指向的是 JobHistory上的位址.
回到“Log Aggregation Status TIME_OUT”這個問題上來,如果有1個控制逾時的參數就可以解決這個問題了,遺憾的是,hadoop2.8.0版本才出現了下面這個參數,我們來看官方的注釋:
<property>
<name>yarn.log-aggregation-status.time-out.ms</name>
<value>600000</value>
<description>
How long for ResourceManager to wait for NodeManager to report its
log aggregation status. If waiting time of which the log aggregation
status is reported from NodeManager exceeds the configured value, RM
will report log aggregation status for this NodeManager as TIME_OUT
</description>
</property>
在更低的hadoop版本中如果要修複這個問題,通過打patch即可解決
備注:
要列印出一個給定應用的所有日志, 指令如下
> yarn logs -applicationId <application ID>