![日誌壓縮不起作用](https://rvso.com/image/928546/%E6%97%A5%E8%AA%8C%E5%A3%93%E7%B8%AE%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
儘管預設啟用了壓縮(我沒有在 中更改它/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
當我嘗試壓縮其中一個/var/log/journal/*/*.journal
檔案時,我發現檔案減少了 5 倍,但我知道已經壓縮的資料無法由其他壓縮器壓縮,因此這些檔案似乎不會壓縮。
我怎樣才能systemd-journald
壓縮我的日記?
答案1
Systemd 似乎不會對整個日誌檔案套用壓縮,而是選擇性地對日誌中的資料塊套用壓縮。正如您自己發現的那樣,這不如批發壓縮。問題是帶大給開發商。