AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 697951
Accepted
Neal Eastwood
Neal Eastwood
Asked: 2022-04-05 08:01:39 +0800 CST2022-04-05 08:01:39 +0800 CST 2022-04-05 08:01:39 +0800 CST

journald RuntimeMaxUse 被忽略,配额绑定到 RuntimeMaxFileSize

  • 772

设置

在内核 4.19.62 上使用 systemd 244 (244.5+)。

我想将总日志存储大小设置为 100MB。Journald 设置为易失性存储,因此日志结束,/run/log/journal/...并且应该使用RuntimeMaxUse在/etc/systemd/journald.conf中设置存储配额,如下所示:

[Journal]
Storage=volatile
RuntimeMaxUse=100M
RuntimeMaxFileSize=2M

通过调整这些配置值,日志日志大小和配额确实会发生变化,并且 journalctl 中的启动消息也会显示变化。

在配置值更改之间,我停止 systemd-journald.service,删除所有system*文件/run/log/journal/...并重新启动服务。

注意:当Storage=persistent和日志使用时/var/log/journal/,等效的SystemMaxUse得到正确尊重。这似乎只是 volatile/RuntimeMaxUse 中的一个错误。

观察到的错误

Runtime MaxUse (100M) 被忽略。只要 Runtime MaxFileSize小于 32M ,日志配额就设置为64MB 。

如果 Runtime MaxFileSize设置为大于 32M,则日志配额设置为该值的两倍。

在这两种情况下,运行时MaxUse似乎都被忽略了。

这是 journald/systemd 配置处理中的错误吗?为什么 Runtime MaxUse被忽略,而使用 64M 或 double Runtime MaxFileSize作为日志配额?

我看到日志源中有几个地方可以将 max_use 设置为双倍 max_size:

  • https://github.com/systemd/systemd/blob/v244/src/journal/journal-file.c#L3747
  • https://github.com/systemd/systemd/blob/v244/src/journal/journal-file.c#L3772

错误示例

设置了64M 的配额(RuntimeMaxUse=100M而RuntimeMaxFileSize=2M不是我要求的 100M),如日志启动消息中所示:

systemd-journald[20312]: Runtime Journal (/run/log/journal/...) is 2.0M, max 64.0M, 62.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 2.0M.
-- Maximum allowed usage is set to 64.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 64.0M, of which 62.0M are still available.

使用RuntimeMaxUse=100Mand RuntimeMaxFileSize=31M,仍然使用 64M:

systemd-journald[20989]: Runtime Journal (/run/log/journal/...) is 8.0M, max 64.0M, 56.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 64.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 64.0M, of which 56.0M are still available.

使用RuntimeMaxUse=100Mand RuntimeMaxFileSize=33M,配额最终为 66M:

systemd-journald[21557]: Runtime Journal (/run/log/journal/...) is 8.0M, max 66.0M, 58.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 66.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 66.0M, of which 58.0M are still available.

使用RuntimeMaxUse=100M并且RuntimeMaxFileSize=200M我们突破了 100M 的限制,400M 似乎来自 200M 的 RuntimeMaxFileSize 的两倍:

systemd-journald[25271]: Runtime Journal (/run/log/journal/...) is 8.0M, max 400.0M, 392.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 400.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 400.0M, of which 392.0M are still available.
systemd systemd-journald
  • 1 1 个回答
  • 364 Views

1 个回答

  • Voted
  1. Best Answer
    Neal Eastwood
    2022-04-12T00:17:11+08:002022-04-12T00:17:11+08:00

    64M 来自一个我不知道的附加配置文件:/lib/systemd/journald.conf.d/00-systemd-conf.conf.

    删除附加设置RuntimeMaxUse=64M后,我现在可以在/etc/systemd/journald.conf.

    提示:在 journald 启动时使用 strace 来查看它真正使用了哪些配置文件以及读取它们的顺序。这就是/lib配置文件最终显示的方式。

    • 2

相关问题

  • journalctl 中的区分级别

  • 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _

  • systemd:如何在服务启动时运行脚本,而不编辑服务定义

  • 使用 systemd 看门狗支持重新启动应用程序

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve