日志存储 = 持久 - 仅磁盘或 RAM 和磁盘

日志存储 = 持久 - 仅磁盘或 RAM 和磁盘

我试图了解 Journald 在日志条目的持久存储方面的作用。我有一个 SDCard 设置,因此我希望将磁盘写入保持在最低限度,但希望通过日志记录保持一定程度的持久性。

开箱即用(Raspbian)journald 使用Storage=autoie,除非有安装,否则/var/log/journal它只会将所有日志存储到 RAM。

问题是,如果存在挂载点/var/log/journal,journald 是否会继续尽可能使用 RAM,还是默认将所有内容写入磁盘?

如果它主要写入 RAM,那么设置什么默认机制来管理日志的持久性?

答案1

从journal.conf 联机帮助页摘录

       Storage=
           Controls where to store journal data. One of "volatile", "persistent", "auto" and "none". If "volatile", journal log data
           will be stored only in memory, i.e. below the /run/log/journal hierarchy (which is created if needed). If "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.  "auto" is
           similar to "persistent" but the directory /var/log/journal is not created if needed, so that its existence controls where
           log data goes.  "none" turns off all storage, all log data received will be dropped. Forwarding to other targets, such as
           the console, the kernel log buffer, or a syslog socket will still work however. Defaults to "auto".

据我所知,在auto模式中,这句话以便它的存在控制日志数据的去向明确指出:

  • 如果没有/var/log/journal,日志仅写入/run/log/journal
  • 使用 时/var/log/journal,日志仅写入/var/log/journal

相关内容