당사 서버의 /var/log 하위 보안 로그는 다음과 같이 1G를 초과합니다.
du -sh * | grep sec
0 secure
4.2G secure-20210726
1.8G secure-20210801
1.2G secure-20210804
따라서 우리는 최대 크기가 100M에 도달한 후 보안 로그를 교체하기로 결정했습니다.
따라서 /etc/logrotate.conf에 다음을 추가합니다.
more /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
/var/log/secure {
monthly
minsize 1M
maxsize 100M
rotate 5
}
/var/log/secure
/etc/logrotate.d/syslog
그런 다음 중복 항목을 피하기 위해 행을 제거했습니다.
마지막으로 로그 회전을 새로 고칩니다.
logrotate /etc/logrotate.conf
잠시 후 /var/log에서 로그 보안을 확인했습니다.
du -sh * | grep sec
0 secure
4.2G secure-20210726
1.8G secure-20210801
1.2G secure-20210804
하지만 위에서 본 것처럼 아무것도 바뀌지 않습니다.
그럼 내 구성에 문제가 있는 걸까요?
ベストアンサー1
구성에는 아무런 문제가 없습니다. 현재 로그 파일에 회전 조건을 적용하며, 회전된 파일의 logrotate
속성(등)을 확인하지 않습니다 .secure-20210726
회전 제한에 도달할 만큼 충분한 파일이 있는 경우에만 회전된 파일의 변경 사항을 볼 수 있으며, 이때 가장 오래된 파일이 삭제됩니다. 압축을 활성화하고 기존 파일을 수동으로 압축할 수 있습니다.