日志相關(guān)的一般配置項(xiàng)
- NodeManager 存儲(chǔ)容器日志文件的本地文件系統(tǒng)中的目錄列表柏肪。
yarn.nodemanager.log-dirs - 選擇是否啟用日志聚合. 如果不啟用聚合, NMs 會(huì)把日志存儲(chǔ)在節(jié)點(diǎn)本地(就像第一代所做的那樣).默認(rèn)值為true
yarn.log-aggregation-enable
yarn.log-aggregation-enable=false
1轰异,容器日志在節(jié)點(diǎn)上的存儲(chǔ)位置, 默認(rèn)值是 ${yarn.log.dir}/userlogs.
2,一個(gè)應(yīng)用的本地化日志目錄是這樣的格式 ${yarn.nodemanager.log-dirs}/application_${appid}
3,一個(gè)獨(dú)立的容器的日志文件夾會(huì)在上面的文件夾下, 文件夾命名格式是這樣 container_${containerid}
4,對(duì)于 MapReduce 的應(yīng)用, 每個(gè)容器目錄下會(huì)包含容器生成的三個(gè)文件, stderr, stdin 和 syslog
5婆咸,當(dāng)yarn.log-aggregation-enable為true時(shí),會(huì)將yarn.nodemanager.log-dirs 目錄下的所有日志聚合到hdfs中芜辕。
yarn.log-aggregation-enable=true
1尚骄,本地目錄不會(huì)有日志,會(huì)隨時(shí)上傳到聚合后的hdfs目錄中侵续。
日志聚合啟用后的相關(guān)配置
應(yīng)用程序結(jié)束時(shí)存儲(chǔ)應(yīng)用程序日志的 HDFS 目錄, 默認(rèn)值/tmp/logs
yarn.nodemanager.remote-app-log-dir將在 {yarn.nodemanager.remote-app-log-dir}/${user}/{thisParam} 創(chuàng)建刪除日志目錄倔丈,這個(gè)目錄下會(huì)有容器的日志,默認(rèn)值logs
yarn.nodemanager.remote-app-log-dir-suffix刪除聚合日志前要保留它們多久,配置成 -1 或者一個(gè)負(fù)值就不會(huì)刪除聚合日志,默認(rèn)值 7天
yarn.log-aggregation.retain-secondscdh中默認(rèn)沒(méi)有這個(gè)屬性状蜗,確定多長(zhǎng)時(shí)間去檢查一次聚合日志的留存情況以執(zhí)行日志的刪除. 如果設(shè)置為 0 或者負(fù)值, 那這個(gè)值就會(huì)用聚合日志的留存時(shí)間的十分之一來(lái)自動(dòng)配置, 默認(rèn)值是 -1.
yarn.log-aggregation.retain-check-interval-seconds
日志聚合未啟用的相關(guān)配置
- 保留用戶日志的時(shí)間(以秒為單位)需五。僅適用在日志聚合已禁用的情況下,默認(rèn)3小時(shí)
yarn.nodemanager.log.retain-seconds
命令行查看方式
[root@datanode1 container-logs]# yarn logs
Retrieve logs for completed YARN applications.
usage: yarn logs -applicationId <application ID> [OPTIONS]
general options are:
-appOwner <Application Owner> AppOwner (assumed to be current user if
not specified)
-containerId <Container ID> ContainerId (must be specified if node
address is specified)
-nodeAddress <Node Address> NodeAddress in the format nodename:port
(must be specified if container id is
specified)