설정

설정

설정

커널 4.19.62에서 systemd 244(244.5+)를 사용합니다.

총 로그 저장 크기를 100MB로 설정하고 싶습니다. Journald는 휘발성 저장소로 설정되어 있으므로 로그는 결국 /run/log/journal/...다음 위치에 저장됩니다.런타임 중 최대 사용량다음과 같이 스토리지 할당량을 설정하는 데 사용해야 합니다./etc/systemd/journald.conf:

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

이러한 구성 값을 조정하면 저널 크기와 할당량이 변경되고, Journalctl의 시작 메시지에도 변경 사항이 표시됩니다.

구성 값이 변경되는 사이에 systemd-journald.service를 중지하고 system*그 아래의 모든 파일을 삭제한 /run/log/journal/...후 서비스를 다시 시작합니다.

노트:Storage=persistentlog 와 함께 사용 하면 /var/log/journal/다음과 같습니다.시스템 최대 사용량올바른 존경을 얻으십시오. 이는 휘발성/RuntimeMaxUse의 버그인 것 같습니다.

관찰된 오류

실행 시간최대 사용량(100M)은 무시됩니다. 저널 할당량은 다음과 같이 설정됩니다.64MB그냥 실행최대 파일 크기32M 미만.

실행 중인 경우최대 파일 크기32M 이상으로 설정하면 로그 할당량은 이 값의 두 배로 설정됩니다.

달리다최대 사용량두 경우 모두 무시되는 것 같습니다.

이것은 Journald/systemd 구성 처리의 버그입니까? 왜 런타임인가?최대 사용량무시합니다. 값은 64M 또는 두 배의 런타임입니다.최대 파일 크기저널 할당량으로 사용됩니까?

로그 소스에서 max_use를 max_size의 두 배로 설정할 수 있는 여러 위치를 볼 수 있습니다.

오류 예

RuntimeMaxUse=100M로그 시작 메시지에 표시된 대로 할당량이 64M로 설정되었습니다 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=100M및 를 사용하고 있으며 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=100M및 를 사용하면 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=100M100M RuntimeMaxFileSize=200M제한을 초과했는데, 400M은 RuntimeMaxFileSize 200M의 두 배에서 나온 것 같습니다.

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.

답변1

내가 모르는 추가 구성 파일의 64M: /lib/systemd/journald.conf.d/00-systemd-conf.conf.

추가 설정을 제거한 후 RuntimeMaxUse=64M이제 에서 원하는 값을 설정할 수 있습니다 /etc/systemd/journald.conf.

팁: 저널이 시작할 때 strace를 사용하여 실제로 사용하는 구성 파일과 해당 파일을 읽는 순서를 확인하세요. 드디어 /lib프로필이 공개되었습니다.

관련 정보