Site icon 지락문화예술공작단

[SYSTEMD] systemd + logrotate 환경에서 “Read-only file system” 에러

OS : RockyLinux9

문제 개요


1. 특정 위치의 logrotation 이 진행되지 않음
원인 : “Read-only file system” 에러를 동반
messages log

logrotate[2848371]: error: failed to rename /usr/local/httpd2/logs/test.com-access_log to /usr/local/httpd2/logs/test.com-access_log-20260202: Read-only file system
logrotate[2848371]: error: failed to rename /usr/local/httpd2/logs/test.com-error_log to /usr/local/httpd2/logs/test.com-error_log-20260202: Read-only file system
logrotate[2848371]: error: error opening /usr/local/php/var/log/php-fpm.log: Read-only file system
logrotate[2848371]: error: error opening /usr/local/php/var/log/slow.log: Read-only file system

2. 업데이트 기록
로그 : /var/log/dnf.log

/var/log/dnf.log.4:2025-12-07T20:04:21+0900 DEBUG —> Package logrotate.x86_64 3.18.0-9.el9 will be upgraded
/var/log/dnf.log.4:2025-12-07T20:04:21+0900 DEBUG —> Package logrotate.x86_64 3.18.0-12.el9 will be an upgrade
/var/log/dnf.log.4:2025-12-07T20:04:21+0900 DEBUG —> Package systemd.x86_64 252-51.el9_6.3.rocky.0.1 will be upgraded
/var/log/dnf.log.4:2025-12-07T20:04:21+0900 DEBUG —> Package systemd.x86_64 252-55.el9_7.7.rocky.0.1 will be an upgrade

3. 로그파일 현황
-rw-r–r– 1 root root  1682882 Dec  5 23:49 access_log-20251206
-rw-r–r– 1 root root  1904115 Dec  6 23:54 access_log-20251207
-rw-r–r– 1 root root 54981516 Feb  2 21:08 access_log
업데이트가 이루어진 2025.12.07 부터 logrotation 이 수행되지 않음
이후로 계속해서 “Read-only file system” 발생
4. logrotate의 “Read-only file system” 원인
RockyLinux9(RHEL9) 에서 작동하는 logrotate 패키지의 보안설정(ProtectSystem) 기본설정에 의한 것으로
임의적인 위치에 존재하는 로그파일들에 대하여
서비스설정파일 (logrotate) 수정으로 처리가 가능하였음
경로 : /lib/systemd/system/logrotate.service
[Service] ReadWritePaths=/usr/local/httpd2/logs ReadWritePaths=/usr/local/php/var/log
그러나 2025.12.07 업데이트가 발생하면서 사용중인 서비스설정파일이
기본값으로 대체되면서 발생한 결과

올바른 방법으로 수정하여, 위험 부담을 줄임


1. 직접 수정
경로 : /etc/systemd/system/logrotate.service.d (없다면 생성)
파일명 : override.conf
“.conf” 로만 끝나면 이름은 아무것이나 상관 없음

[Service]
ReadWritePaths=/usr/local/httpd2/logs
ReadWritePaths=/usr/local/php/var/log

2. systemd command 를 이용하여 설정파일 추가
systemctl edit logrotate

### Editing /etc/systemd/system/logrotate.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Service]
ReadWritePaths=/usr/local/httpd2/logs
ReadWritePaths=/usr/local/tomcat/logs
ReadWritePaths=/usr/local/php/var/log

### Lines below this comment will be discarded

표시된 “### Lines below this comment will be discarded“ 부분 아래는 무시 되기 때문에
해당 라인 상단에 내용을 추가해야 한다
내용 추가 후 저장&닫기 를 마치면
override.conf 파일이 동일한 내용으로 생성된것을 확인할 수 있다
systemctl 명령으로도 추가된 내용 확인이 가능

systemctl cat logrotate

3. 적용 및 서비스 재시작
systemctl daemon-reload
systemctl restart logrotate
로그 분리를 바로 확인하고 싶다면

logrotate -f /etc/logrotate.conf

Exit mobile version