日志压缩不起作用

Jue*_*gen 5 systemd-journald

尽管默认情况下启用了压缩(我没有在 中更改它/etc/systemd/journald.conf),但我的 Ubuntu 18 LTS 服务器中的日志文件似乎没有被压缩,并且journalctl声称可以看到压缩文件:

# journalctl --header | grep PRESS | uniq
Incompatible Flags: COMPRESSED-LZ4

# journalctl --disk-usage
Archived and active journals take up 4.0G in the file system.

# journalctl -o verbose | wc
4 GB in 90 Mio lines  # about the same size as the journal files itself

# journalctl -o verbose | gzip | wc -c
193 MB  # reduced by a factor of 20

grep -v '^#' /etc/systemd/journald.conf
[Journal]
Storage=persistent
SystemMaxUse=4G
SystemKeepFree=4G
SystemMaxFileSize=100M
MaxFileSec=1week
SyncIntervalSec=1
LineMax=1K
ForwardToConsole=yes
MaxLevelConsole=crit
MaxLevelWall=alert
RateLimitIntervalSec=2min
RateLimitBurst=2000
Run Code Online (Sandbox Code Playgroud)

当我尝试压缩其中一个文件时/var/log/journal/*/*.journal,我发现文件减少了 5 倍,但我知道已经压缩的数据无法由其他压缩器压缩,因此这些文件似乎未压缩。

我怎样才能systemd-journald压缩我的日记?

Adr*_*ian 3

Systemd 似乎不会对整个日志文件应用压缩,而是有选择地对日志中的数据块应用压缩。正如您自己发现的那样,这不如批发压缩。该问题已向开发商提出。