본문 바로가기

Infra

Journal Log 용량 제한

Controller : 1GB

  • Container : 500MB

Compute : 1GB

Stroage : 1GB

 

[Compute node, Storage node]

vi /etc/systemd/journald.conf

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the journald.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.
#
# See journald.conf(5) for details.

[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=1G # 설정
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
RuntimeMaxUse=1G # 설정
#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
#LineMax=48K
#ReadKMsg=yes
#Audit=no

systemctl restart systemd-journald

 

[Controller node]

controller의 경우 아래 스크립트를 통해 설정

root@testbed-deploy:~# cat journal-limit.sh
#!/bin/sh

limit="500M"
limit_host="1G"

readarray -t container_ids < <(lxc-ls -1)
echo $container_ids

update_journald_conf() {
        local container_id=$1
        local limit_var=$2
        echo "-------------------------------------------------------"
        echo "update $container_id, set to $limit_var"
        echo "-------------------------------------------------------"
        lxc-attach $container_id -- journalctl --disk-usage
        lxc-attach $container_id -- bash -c "echo '#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the journald.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.
#
# See journald.conf(5) for details.

[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=$limit_var
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
RuntimeMaxUse=$limit_var
#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
#LineMax=48K
#ReadKMsg=yes
#Audit=no
' > /etc/systemd/journald.conf"
        lxc-attach $container_id -- cat /etc/systemd/journald.conf
        lxc-attach $container_id -- systemctl restart systemd-journald
        lxc-attach $container_id -- journalctl --disk-usage
}

df -h

echo ""

journalctl --disk-usage
echo "#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the journald.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.
#
# See journald.conf(5) for details.

[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=$limit_host
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
RuntimeMaxUse=$limit_host
#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
#LineMax=48K
#ReadKMsg=yes
#Audit=no
" > /etc/systemd/journald.conf
systemctl restart systemd-journald
journalctl --disk-usage
echo ""

for ((i = 0; i < ${#container_ids[@]} - 1; i++)); do
    update_journald_conf "${container_ids[i]}" "$limit"
done

df -h

'Infra' 카테고리의 다른 글

SR-IOV와 VF 개수 상관 관계  (0) 2024.06.26
Mellanox 설치  (0) 2024.05.25
Squid proxy 폐쇄망 연결  (0) 2024.05.23
sFlow Dashboard  (0) 2024.05.23
OpenVSwitch sFlow  (0) 2024.05.23