MariaDB 서버 중 하나의 logrotate에 문제가 있습니다. Logrotate는 아무런 오류없이 (apperently) 실행 중입니다. mariadb-slow.log 파일을 회전 한 후 MariaDB는 새 로그 파일에 메시지를 쓰지 않습니다. 이 문제는 mariadb-slow.log에만 영향을 미칩니다.logrotate 후 MariaDB 저속 로그가 기록되지 않음
logrotate 구성 파일의 postrotate 섹션에서 mysqladmin 명령을 실행하면 maraidb-slow.log가 다시 기록됩니다.
mysqladmin --defaults-file="/etc/mysql/debian.cnf" --local flush-error-log flush-engine-log flush-general-log flush-slow-log
수동으로 logrotate를 실행하면 문제가 발생합니다. 에 -v 매개 변수를 추가
logrotate /etc/logrotate.d/mysql-server
은 logrotate에 구성 파일이 패키지 관리자에서 하나입니다
logrotate -v /etc/logrotate.d/mysql-server
reading config file /etc/logrotate.d/mysql-server
Reading state from file: /var/lib/logrotate/status
Allocating hash table for state file, size 64 entries
Creating new state
...
Creating new state
Handling 1 logs
rotating pattern: /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log 1024 bytes (7 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/mysql/mysql.log
log /var/log/mysql/mysql.log does not exist -- skipping
considering log /var/log/mysql/mysql-slow.log
log /var/log/mysql/mysql-slow.log does not exist -- skipping
considering log /var/log/mysql/mariadb-slow.log
Now: 2017-11-15 15:02
Last rotated at 2017-11-15 13:54
log needs rotating
considering log /var/log/mysql/error.log
Now: 2017-11-15 15:02
Last rotated at 2017-11-15 13:54
log needs rotating
rotating log /var/log/mysql/mariadb-slow.log, log->rotateCount is 7
dateext suffix '-20171115'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/mysql/mariadb-slow.log.7.gz to /var/log/mysql/mariadb-slow.log.8.gz (rotatecount 7, logstart 1, i 7),
renaming /var/log/mysql/mariadb-slow.log.6.gz to /var/log/mysql/mariadb-slow.log.7.gz (rotatecount 7, logstart 1, i 6),
old log /var/log/mysql/mariadb-slow.log.6.gz does not exist
renaming /var/log/mysql/mariadb-slow.log.5.gz to /var/log/mysql/mariadb-slow.log.6.gz (rotatecount 7, logstart 1, i 5),
renaming /var/log/mysql/mariadb-slow.log.4.gz to /var/log/mysql/mariadb-slow.log.5.gz (rotatecount 7, logstart 1, i 4),
renaming /var/log/mysql/mariadb-slow.log.3.gz to /var/log/mysql/mariadb-slow.log.4.gz (rotatecount 7, logstart 1, i 3),
renaming /var/log/mysql/mariadb-slow.log.2.gz to /var/log/mysql/mariadb-slow.log.3.gz (rotatecount 7, logstart 1, i 2),
renaming /var/log/mysql/mariadb-slow.log.1.gz to /var/log/mysql/mariadb-slow.log.2.gz (rotatecount 7, logstart 1, i 1),
renaming /var/log/mysql/mariadb-slow.log.0.gz to /var/log/mysql/mariadb-slow.log.1.gz (rotatecount 7, logstart 1, i 0),
old log /var/log/mysql/mariadb-slow.log.0.gz does not exist
rotating log /var/log/mysql/error.log, log->rotateCount is 7
dateext suffix '-20171115'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/mysql/error.log.7.gz to /var/log/mysql/error.log.8.gz (rotatecount 7, logstart 1, i 7),
renaming /var/log/mysql/error.log.6.gz to /var/log/mysql/error.log.7.gz (rotatecount 7, logstart 1, i 6),
renaming /var/log/mysql/error.log.5.gz to /var/log/mysql/error.log.6.gz (rotatecount 7, logstart 1, i 5),
renaming /var/log/mysql/error.log.4.gz to /var/log/mysql/error.log.5.gz (rotatecount 7, logstart 1, i 4),
renaming /var/log/mysql/error.log.3.gz to /var/log/mysql/error.log.4.gz (rotatecount 7, logstart 1, i 3),
renaming /var/log/mysql/error.log.2.gz to /var/log/mysql/error.log.3.gz (rotatecount 7, logstart 1, i 2),
renaming /var/log/mysql/error.log.1.gz to /var/log/mysql/error.log.2.gz (rotatecount 7, logstart 1, i 1),
renaming /var/log/mysql/error.log.0.gz to /var/log/mysql/error.log.1.gz (rotatecount 7, logstart 1, i 0),
old log /var/log/mysql/error.log.0.gz does not exist
renaming /var/log/mysql/mariadb-slow.log to /var/log/mysql/mariadb-slow.log.1
creating new /var/log/mysql/mariadb-slow.log mode = 0640 uid = 110 gid = 4
renaming /var/log/mysql/error.log to /var/log/mysql/error.log.1
creating new /var/log/mysql/error.log mode = 0640 uid = 110 gid = 4
running postrotate script
compressing log with: /bin/gzip
removing old log /var/log/mysql/mariadb-slow.log.8.gz
compressing log with: /bin/gzip
removing old log /var/log/mysql/error.log.8.gz
눈에 띄는 아무것도 표시되지 않습니다. 나는 어떤 수정도하지 않았다. 나는 또한 다른 것들을 시도했다.
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log {
# daily
size 1k
rotate 7
missingok
create 640 mysql adm
compress
sharedscripts
postrotate
test -x /usr/bin/mysqladmin || exit 0
if [ -f `my_print_defaults --mysqld | grep -m 1 -oP "pid-file=\K.+$"` ]; then
# If this fails, check debian.conf!
mysqladmin --defaults-file=/etc/mysql/debian.cnf -v --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log >> /var/log/mysql-logrotate.log 2>&1
fi
endscript
}
이 문제에 대한 학습 후, 난 그냥
>> /var/log/mysql-logrotate.log 2>&1
그러나 MySQL의-logrotate.log는 빈칸을 추가했다.
소프트웨어 사용 : OS : 데비안 9.1 DB : MariaDB 10.1 logrotate에 : 3.11.0