docker日志出現(xiàn)無(wú)法檢索問(wèn)題的解決
日常檢查服務(wù)的時(shí)候,從portainer那里進(jìn)去看容器日志的時(shí)候,發(fā)現(xiàn)右上角出現(xiàn)紅色的感嘆號(hào):Unable to retrieve container logs。
因?yàn)橹皼](méi)出現(xiàn)過(guò)這樣的問(wèn)題,所以就先上服務(wù)器上用命令docker logs -f containerID看日志,發(fā)現(xiàn)日志也是動(dòng)不了,還是停留在某個(gè)時(shí)間的日志記錄上。
想了一下不應(yīng)該是服務(wù)的日志打印出問(wèn)題,先照著Google搜索了一遍,發(fā)現(xiàn)都沒(méi)有跟我的問(wèn)題相匹配的。因?yàn)槿罩居袝r(shí)能收集顯示,有些日志不可以,應(yīng)該是跟docker設(shè)置的日志引擎有問(wèn)題。
本來(lái)是想整一套EFK的,但是感覺(jué)現(xiàn)在日志量還不夠大,所以并沒(méi)有修改docker的日志引擎,還是默認(rèn)的journald
[root@ad-official xiaoxiao]# docker info|grep Logging WARNING: You're not using the default seccomp profile Logging Driver: journald
journald的官方文檔上有這么一個(gè)說(shuō)明:
man journald.conf ... RateLimitInterval=, RateLimitBurst= Configures the rate limiting that is applied to all messages generated on the system. If, in the time interval defined by RateLimitInterval=, more messages than specified in RateLimitBurst= are logged by a service, all further messages within the interval are dropped until the interval is over. A message about the number of dropped messages is generated. This rate limiting is applied per-service, so that two services which log do not interfere with each other's limits. Defaults to 1000 messages in 30s. The time specification for RateLimitInterval= may be specified in the following units: "s", "min", "h", "ms", "us". To turn off any kind of rate limiting, set either value to 0. ...
這里寫(xiě)了默認(rèn)30秒內(nèi)只能接收1000條日志,看到這里就能明白了,因?yàn)榍瓣囎觿傇赿ocker發(fā)布了一個(gè)單日日志文件大小差不多達(dá)到3G的服務(wù),導(dǎo)致到了其他服務(wù)的日志也受到了影響,大量的日志被journald丟棄,所以我們修改一下配置就沒(méi)有問(wèn)題了。
打開(kāi)/etc/systemd/journald.conf文件,將RateLimitBurst從默認(rèn)的1000修改成5000,根據(jù)自己目前的日志輸出量進(jìn)行調(diào)整:
[root@ad-official log]# cat /etc/systemd/journald.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See journald.conf(5) for details. [Journal] #Storage=auto #Compress=yes #Seal=yes #SplitMode=uid #SyncIntervalSec=5m #RateLimitInterval=30s RateLimitBurst=5000 #SystemMaxUse= #SystemKeepFree= #SystemMaxFileSize= #RuntimeMaxUse= #RuntimeKeepFree= #RuntimeMaxFileSize= #MaxRetentionSec= #MaxFileSec=1month ForwardToSyslog=no #ForwardToKMsg=no #ForwardToConsole=no ForwardToWall=no #TTYPath=/dev/console #MaxLevelStore=debug #MaxLevelSyslog=debug #MaxLevelKMsg=notice #MaxLevelConsole=info #MaxLevelWall=emerg #LineMax=48K
順便將ForwardToSyslog和ForwardToWall設(shè)置成no,因?yàn)槟J(rèn)是yes,會(huì)導(dǎo)致我們清理了journal的日志文件,而Syslog中的沒(méi)有清除掉,慢慢的就會(huì)將磁盤(pán)占滿(mǎn)。
然后重啟一下journald就可以恢復(fù)正常使用啦:systemctl restart systemd-journald.service
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- docker中的環(huán)境變量使用與常見(jiàn)問(wèn)題解決方案
- Docker解決終端無(wú)法輸入中文的問(wèn)題
- Docker暴露2375端口導(dǎo)致服務(wù)器被攻擊問(wèn)題及解決方法
- Docker 安裝 Jenkins 并解決初始安裝插件失敗問(wèn)題
- 解決docker容器無(wú)法ping外網(wǎng)的問(wèn)題
- Docker環(huán)境搭建Jenkins在構(gòu)建任務(wù)時(shí)控制臺(tái)日志出現(xiàn)中文亂碼的問(wèn)題
- 分享Ubuntu19無(wú)法安裝docker源問(wèn)題
- Docker 常見(jiàn)問(wèn)題解決
相關(guān)文章
Jenkins Docker靜態(tài)agent節(jié)點(diǎn)的構(gòu)建過(guò)程
這篇文章主要介紹了Jenkins Docker靜態(tài)agent節(jié)點(diǎn)的構(gòu)建,靜態(tài)節(jié)點(diǎn)就是通過(guò)java -jar這條命令去啟動(dòng)起來(lái)就可以了,本文通過(guò)圖文實(shí)例相結(jié)合給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-10-10Docker快速搭建PHP+Nginx+Mysql環(huán)境及踩坑
本文主要介紹了Docker快速搭建PHP+Nginx+Mysql環(huán)境及踩坑 ,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08使用OpenSSL生成Kubernetes證書(shū)的介紹
今天小編就為大家分享一篇關(guān)于使用OpenSSL生成Kubernetes證書(shū)的介紹,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-01-01docker部署釘釘機(jī)器人報(bào)警通知的實(shí)現(xiàn)
本文主要介紹了docker部署釘釘機(jī)器人報(bào)警通知的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05使用Dockerfile構(gòu)建java web環(huán)境
用dockerfile構(gòu)建一個(gè)Java的web環(huán)境,主要分為2步,第一步是在鏡像中安裝jdk并配置環(huán)境變量,第二步是安裝tomcat,下面分步驟給大家詳細(xì)介紹,一起看看吧2016-12-12Docker容器應(yīng)用中,10個(gè)要不得的壞習(xí)慣
這篇文章主要介紹了Docker容器的應(yīng)用中,10個(gè)要不得的壞習(xí)慣,幫助大家更好的理解和使用docker,感興趣的朋友可以了解下2020-08-08