Problem solved but I'm writing down for the future reference.
/root/.my.cnf
[mysqladmin]
user = root
password = pa$$w0rd
/etc/logrotate.d/mysql
/var/log/mysql-slow.log /var/log/mysqld.log {
daily
rotate 7
dateext
compress
missingok
#notifempty
sharedscripts
create 644 mysql mysql
postrotate
/usr/bin/mysqladmin flush-logs
endscript
}
logrotate
is working fine when running from the command line:
# logrotate -v -f /etc/logrotate.d/mysql
but it doesn't work when running from cron at 4 A.M. The logs file was rotated but MySQL doesn't logs the error to newly created file:
-rw-r--r-- 1 mysql mysql 0 Aug 7 10:13 /var/log/mysqld.log
-rw-r--r-- 1 mysql mysql 20 Aug 4 04:04 /var/log/mysqld.log-20120804.gz
-rw-r--r-- 1 mysql mysql 20 Aug 5 04:04 /var/log/mysqld.log-20120805.gz
-rw-r--r-- 1 mysql mysql 20 Aug 6 16:28 /var/log/mysqld.log-20120806.gz
In the
postrotate
, I redirect both stderr and stdout to a log file to see what happens:What I get is:
It sounds like
mysqladmin
doesn't read/root/.my.cnf
during logrotate.So, try this:
Source:
I had a similar problem.
I didn't restart MySQL after adding
/root/.my.cnf
, so the postrotate flush command wasn't run.Once I restarted MySQL it read the root my.cnf file and worked as expected.
In my case, the block in
/etc/logrotate.d/mysql
looked a bit different:Note the comment: "If this fails, check debian.conf!" and the command having the parameter
--defaults-file=/etc/mysql/debian.cnf
. This file had the very same[client]
section, defining userroot
with an empty password. So obviously, the very same password used in/root/.my.cnf
had to be placed in that file as well. Security-wise,/etc/mysql/debian.cnf
is similar to/root/.my.cnf
: owned byroot:root
, and chmodded to0600
.So, In my case, There's a permission problem to
debian-sys-maint
user, because of, thegalera-cluster
has the same integrity on each node, although, each node install individually, by the debian user for each one, which, the config file is/etc/mysql/debian.cnf
So in the
logrotate
file is:The solution so simple, just, change the password of
debian-sys-maint
user on one node, and set the password on the '/etc/mysql/debian.cnf' file on every nodesI hope, it be useful, as mine.
In my case. I need have been set
--defaults-file="/root/.my.cnf"
to/root/.my.cnf
in/usr/local/mysql/bin/mysqladmin --defaults-file="/root/.my.cnf" ping
and/usr/local/mysql/bin/mysqladmin --defaults-file="/root/.my.cnf" flush-logs
/etc/logrotate.d/mysql
My
/root/.my.cnf
have-rw------- 1 root root 43 Mar 21 20:51 .my.cnf