https://access.redhat.com/solutions/696893
SOLUTION 已验证 - 已更新 2019年一月18日00:39 -
环境
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
问题
- The
systemd
journal is configured by default to store logs only in a small ring-buffer in/run/log/journal
, which is not persistent - Journal database logs do not survive a system reboot
决议
- Configure
systemd
to persistently store journal logs in/var/log/journal
by running the following commands.
# mkdir -p /var/log/journal
- You may decide if you need to keep or remove the
rsyslog
package installed on the system at this point, depending on your requirements - See
man journalctl
for more information on querying the journal database for specific logs
Instead of manually creating the /var/log/journal directory, one can also change the systemd-journald configuration file:
# sed -i 's/#Storage=auto/Storage=persistent/' /etc/systemd/journald.conf
# systemctl restart systemd-journald.service
With storage option "persistent", data will be stored preferably on disk, i.e. below the /var/log/journal hierarchy (which is created if needed), with a fallback to /run/log/journal (which is created if needed), during early boot and if the disk is not writable.
根源
- By default in Red Hat Enterprise Linux 7 and 8,
systemd
is not configured to maintain logs persistently