Redhat Linux 9: Mô tả cách tương tác với Systemd Journal



Redhat Linux 9: Mô tả cách tương tác với Systemd Journal

Redhat Linux 9:  Mô tả cách tương tác với Systemd Journal

Link playlist
Red Hat Enterprise Linux Administration
https://www.youtube.com/playlist?list=PLIpLw6v7Z1qnIUiJipjgYEHwxF16TZbCN
2023 08 16 15 47 11

Preserving the Systemd Journal By default, the journal is stored in the file /run/log/journal. The entire /run directory is used for current process status information only, which means that the journal is cleared when the system reboots. To make the journal persistent between system restarts, you should create a directory /var/log/journal. Storing the journal permanently requires the Storage=auto parameter in /etc/systemd/journald.conf, which is set by default. This parameter can have different values: Storage=auto The journal will be written on disk if the directory /var/log/journal exists. Storage=volatile The journal will be stored only in the /run/log/journal directory.
Storage=persistent The journal will be stored on disk in the directory /var/log/journal. This directory will be created automatically if it doesn’t exist. Storage=none No data will be stored, but forwarding to other targets such as the kernel log buffer or syslog will still work. Even when the journal is written to the permanent file in /var/log/journal, that does not mean that the journal is kept forever. The journal has built-in log rotation that will be used monthly. Also, the journal is limited to a maximum size of 10 percent of the size of the file system that it is on, and it will stop growing if less than 15 percent of the file system is still free. If that happens, the oldest messages from the journal are dropped automatically to make room for newer messages. To change these settings, you can modify the file /etc/systemd/journald.conf, as shown in Example 13-5 (along with other parameters you can set). Example 13-5 Setting journald Parameters Through /etc/systemd/journald.conf Click here to view code image
[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
#SystemMaxUse=
#SystemKeepFree=
#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
Making the systemd journal permanent is not hard to do. Exercise 13-3 shows how to proceed. Exercise 13-3 Making the systemd Journal Persistent 1. Open a root shell and type mkdir /var/log/journal. 2. Before journald can write the journal to this directory, you have to set ownership. Type chown root:systemd-journal /var/log/journal, followed by chmod 2755 /var/log/journal. 3. Use systemctl restart systemd-journal-flush to reload the new systemd-journald parameters. 4. The Systemd journal is now persistent across reboots.