MariaDB/Admin
[MariaDB][운영] CentOS7에서 logrodate로 로그 파일이 rotation되지 않을 경우
알 수 없는 사용자
2016. 8. 9. 15:29
[테스트 환경]
OS : CentOS 7
DB : MariaDB 10.1.12
1. logrodate를 실행해도 slow로그 파일이 생성되지 않는 현상
-- logrotate 실행 [root@localhost /etc/logrotate.d]$logrotate -f /etc/mysql-log-rotate -- 파일이 새로 생성되지 않음을 확인 [root@localhost /maria_log/slow]$ls -al /maria_log/slow 합계 88 drwxr-xr-x. 2 maria dba 4096 8월 8 17:48 . drwxr-xr-x. 8 maria dba 4096 4월 12 08:23 .. -rw-rw----. 1 maria dba 180 8월 8 17:48 mysql-slow-query.log
2. 문제해결
-- logrotate.conf 파일 확인 시 mysql-log-rotate 파일에 문제가 있음을 확인 [root@localhost /etc/logrotate.d]$logrotate -f -v /etc/logrotate.conf reading config file /etc/logrotate.conf including /etc/logrotate.d Ignoring mysql-log-rotate because of bad file mode. reading config file ppp reading config file syslog reading config file wpa_supplicant reading config file yum Handling 6 logs -- mysql-log-rotate 권한이 644가 아니여서 에러가 발생함 [root@localhost /etc/logrotate.d]$ls -al /etc/logrotate.d 합계 28 drwxr-xr-x. 2 root root 4096 8월 8 17:42 . drwxr-xr-x. 76 root root 4096 8월 8 17:35 .. -rwxr-xr-x. 1 root root 966 8월 8 17:42 mysql-log-rotate -rw-r--r--. 1 root root 136 6월 10 2014 ppp -rw-r--r--. 1 root root 224 9월 8 2015 syslog -rw-r--r--. 1 root root 100 6월 16 2015 wpa_supplicant -rw-r--r--. 1 root root 100 12월 4 2015 yum -- mysql-log-rotate 권한을 644로 변경 [root@localhost /etc/logrotate.d]$chmod 644 /etc/logrotate.d/mysql-log-rotate [root@localhost /etc/logrotate.d]$ls -al /etc/logrotate.d 합계 28 drwxr-xr-x. 2 root root 4096 8월 8 17:42 . drwxr-xr-x. 76 root root 4096 8월 8 17:35 .. -rw-r--r--. 1 root root 966 8월 8 17:42 mysql-log-rotate -rw-r--r--. 1 root root 136 6월 10 2014 ppp -rw-r--r--. 1 root root 224 9월 8 2015 syslog -rw-r--r--. 1 root root 100 6월 16 2015 wpa_supplicant -rw-r--r--. 1 root root 100 12월 4 2015 yum -- logrotate.conf 파일 재확인 [root@localhost /etc/logrotate.d]$logrotate -f -v /etc/logrotate.conf reading config file /etc/logrotate.conf including /etc/logrotate.d reading config file mysql-log-rotate reading config file ppp reading config file syslog reading config file wpa_supplicant reading config file yum Handling 7 logs -- logrotate 실행 [root@localhost /etc/logrotate.d]$logrotate -f /etc/mysql-log-rotate -- 생성된 log파일 확인 [root@localhost /maria_log/slow]$ls -al /maria_log/slow 합계 88 drwxr-xr-x. 2 maria dba 4096 8월 8 17:48 . drwxr-xr-x. 8 maria dba 4096 4월 12 08:23 .. -rw-rw----. 1 maria dba 180 8월 8 17:48 mysql-slow-query.log -rw-rw----. 1 maria dba 180 8월 8 17:48 mysql-slow-query.log.1 -rw-rw----. 1 maria dba 180 8월 8 17:48 mysql-slow-query.log.2 -rw-rw----. 1 maria dba 180 8월 8 17:47 mysql-slow-query.log.3