In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to understand the docker log engine, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Docker natively supports many log engines and is suitable for various application scenarios. The editor gives a brief description of it.
Description of the Docker logging engine
The following logging engines are supported by docker:
None: turn off the echo log of docker. Docker logs can't see any output. Using this approach also means that you cannot view the logs of any container output.
Json-file: type the echo log of each container to the inside of each container in the form of a json file. In practical use, some containers have a large number of echo logs after startup, especially when an error is reported inside the program, which is likely to burst the disk of the entire host because the json logs of some containers are too large.
Syslog: type the echo logs of all containers into the system's syslog.
Currently, if the harbor private image repository is started using docker-compose, this method is used by default. Collect the logs of all containers centrally into a harbor-log container, and prompt "logs" command is supported only for "json-file" and "journald" loggin drivers (got: syslog) when executing docker logs.
Journald: it is recommended to type the echo logs of all containers into the system's journald service.
Fluentd: type the echo logs of all containers into the fluentd service.
Gelf types echo logs from all containers into services that support the GELF (Graylog Extended Log Format) format, such as Graylog or Logstash.
Modify the docker logging engine
Modify the docker configuration file / etc/docker/daemon.json as follows:
{"log-driver": "journald"}
Specify its logging engine while the container is running:
Docker run-log-driver=journald alpint / bin/sh
Journald profile description
# / etc/systemd/jornald.conf example:
[Journal] # Storage=auto is stored in automatic mode, other modes include no log mode, pure memory mode and pure disk mode # Compress=yes enables compression by default # Seal=yes default encryption, log files are binary files Unable to view vim or tail # SplitMode=uid#SyncIntervalSec=5m#RateLimitIntervalSec=30s#RateLimitBurst=1000#SystemMaxUse= precisely sets the maximum disk space that the log can occupy # SystemKeepFree= guarantees the amount of space left on the system # SystemMaxFileSize=#SystemMaxFiles=100#RuntimeMaxUse=#RuntimeKeepFree=#RuntimeMaxFileSize=#RuntimeMaxFiles=100#MaxRetentionSec=#MaxFileSec=1month#ForwardToSyslog=no#ForwardToKMsg=no#ForwardToConsole=no#ForwardToWall=yes#TTYPath=/dev/console#MaxLevelStore=debug#MaxLevelSyslog=debug#MaxLevelKMsg=notice#MaxLevelConsole=info#MaxLevelWall=emerg
Under the default configuration of journald, the default log is limited to 10% of the capacity of the file system it resides in.
By default, journald logs are stored under / var/log/journal. If the directory is under the root partition and the space size of the root partition is 10G, then the maximum size of journald logs is 1G. If it exceeds 1G, the oldest log will be deleted.
You can also specify exactly how much space is occupied:
SystemMaxUse=50M
Basic usage of journalctl
Journalctl view all logs from scratch journalctl-b view all system boot logs after this boot journalctl-b-1 shows the system boot logs after the last boot, and so on journalctl-f is similar to tail-f or tailfjournalctl / usr/bin/dockerd after the absolute path of the program, can display all the log information of the program journalctl-xe systemd will prompt you to view error messages when the program fails to start Where x means to add some explanatory short text to the log output, and e means to jump to the end of the log immediately.
Considerations for journald
There are two very important optimizations in the journald configuration:
ForwardToSyslog=yesForwardToWall=yes
The above two parameters are yes by default, which means that journald collects logs and forwards them to syslog.
The resulting impact is that although journald can obediently clean up the logs according to the above configuration, syslog is not under the control of journald.
When the log volume is very large, the log volume in syslog becomes huge, so we need to change the values of the above two parameters to no.
Restart the journald service
Systemctl restart systemd-journald.service on how to understand the docker logging engine to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.