Como fazer o journald aumentar a capacidade de armazenamento de logs?

1

Eu gostaria de ter logs persistentes via journald. Eu criei /var/log/journal e recarreguei o serviço. Agora os logs são salvos no disco. Mas o limite de tamanho do log é baixo.

Adicionei /etc/systemd/journald.conf . ( Storage=persistent/auto não importa, eu tentei os dois).

[Journal]
Storage=persistent
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitInterval=30s
#RateLimitBurst=1000
#SystemMaxUse=
SystemKeepFree=10G
SystemMaxFileSize=1G
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg

Como você pode ver, eu só mudei o tamanho de cada arquivo de diário para 1Gb e disse que eu quero 10Gb livre no disco.

Mas journald me diz que ele tem apenas 4 GB de capacidade de armazenamento de log.

$ sudo systemctl status systemd-journald
...
jan 20 15:44:26 host systemd-journald[1218]: System journal (/var/log/journal/) is 4.5G, max 4.0G, 0B free.
jan 20 15:44:26 host systemd-journald[1218]: Journal started

O que eu perdi?

$ systemctl --version
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN
    
por 4xy 20.01.2018 / 15:51

2 respostas

1

É necessário configurar SystemMaxUse=100G , por exemplo

    
por 20.01.2018 / 20:34
0

Na página homem :

SystemMaxUse=, SystemKeepFree=, SystemMaxFileSize=, SystemMaxFiles=, RuntimeMaxUse=, RuntimeKeepFree=, RuntimeMaxFileSize=, RuntimeMaxFiles=

[...]

The first pair defaults to 10% and the second to 15% of the size of the respective file system, but each value is capped to 4G. If the file system is nearly full and either SystemKeepFree= or RuntimeKeepFree= are violated when systemd-journald is started, the limit will be raised to the percentage that is actually free. This means that if there was enough free space before and journal files were created, and subsequently something else causes the file system to fill up, journald will stop using more space, but it will not be removing existing files to reduce the footprint again, either.

Então, sim, no máximo, em 4G , no entanto , o seguinte é interessante no seu caso:

journalctl and systemd-journald ignore all files with names not ending with ".journal" or ".journal~", so only such files, located in the appropriate directories, are taken into account when calculating current disk usage.

Portanto, mover os arquivos de log regularmente permite contornar a limitação. Note que você terá que garantir que os logs não preencham seu sistema de arquivos de alguma forma, removendo arquivos de log antigos! Você poderia, digamos, ter 1 arquivo no máximo 1G, verificar regularmente e mover o arquivo para ${filename}.n , onde n é 1-9, tendo no máximo 10G ... desde que você mova os arquivos quando eles atingirem 1G em tamanho para o mais antigo ${filename}.n . Para ler os logs, você desconsidera o nome, do mais antigo ao mais novo ...

    
por 20.01.2018 / 19:22