I had a server crash over the weekend and discovered that I don't know
as much about MySQL error logging as I thought. The error logs were
empty because of FLUSH LOGS.
What I learned today is if I specify the log-errors parameter in
/etc/mysql/my.cnf, every time there's a FLUSH LOGS (or mysqld catches a
SIGHUP), it rotates the error log to -old, like this:
Here's the config file line:
log-error = /var/log/mysql/mysqld.err
And here's the directory:
$ ls -l /var/log/mysql/
-rw-rw---- 1 mysql mysql 0 Jul 11 08:40 mysql.err
-rw-rw---- 1 mysql mysql 1617643 Oct 8 11:26 mysqld.err
-rw-rw---- 1 mysql mysql 61984 Oct 8 11:22 mysqld.err-old
I created those logs by deliberately making InnoDB spit out some output
with the InnoDB Lock Monitor, then did a FLUSH LOGS, and mysqld itself
moved mysqld.err to mysqld.err-old.
If I don't specify log-error, it doesn't log anything (duh). In this
case, the output goes where? to mysql.err instead of mysqld.err? No,
that file is created by mysqld_safe and never seems to get anything
written to it. It seems to go to /dev/null, or maybe it just isn't
logging anything at all when log-error isn't specified.
The problem here is that the renaming is throwing away my error
messages, which I need to debug a problem. And I don't just want this
file written in the data directory, so I don't want to omit the filename
and let MySQL choose where the file goes (which appears to be the only
way to avoid the auto-renaming behavior, according to the manual section
I do not like this auto-rotating behavior. I want to use logrotate to
handle this. Is there any way I can configure MySQL to just log to the
specified file, do a close-and-reopen when I run FLUSH LOGS like it does
for the other logs, and use logrotate to rotate the files myself?
|• How to get sane error log behavior||Baron Schwartz||8 Oct|