| Bug #73949 | mysql's error-log name in logrotate script is wrong | ||
|---|---|---|---|
| Submitted: | 17 Sep 2014 11:58 | Modified: | 15 Dec 2016 12:56 |
| Reporter: | Shahriyar Rzayev | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Installing | Severity: | S1 (Critical) |
| Version: | 5.6.20 | OS: | Linux (CentOS 6.5) |
| Assigned to: | CPU Architecture: | Any | |
[18 Sep 2014 0:43]
MySQL Verification Team
Thank you for the bug report. Quoting you: 2. Official documentation states that: "Default log file name will be hostname.err and will reside in datadirectory if not specified explicitly". The above means IF NOT SPECIFIED EXPLICITLY. but on Centos 6.5: [root@tikal miguel]# cat /etc/my.cnf | grep mysqld.log log-error=/var/log/mysqld.log So the log-error file is specified explicitly as mysqld.log and testing removing it from my.cnf commentin it: [root@tikal miguel]# cat /etc/my.cnf | grep mysqld.log #log-error=/var/log/mysqld.log stop the server and start it and now the log-error file is hostname.err: [root@tikal miguel]# service mysqld start Starting mysqld: [ OK ] [root@tikal miguel]# cat /var/lib/mysql/tikal.br.err 140917 21:32:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2014-09-17 21:32:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2014-09-17 21:32:01 5320 [Note] Plugin 'FEDERATED' is disabled. 2014-09-17 21:32:01 5320 [Note] InnoDB: Using atomics to ref count buffer pool pages 2014-09-17 21:32:01 5320 [Note] InnoDB: The InnoDB memory heap is disabled 2014-09-17 21:32:01 5320 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2014-09-17 21:32:01 5320 [Note] InnoDB: Memory barrier is not used 2014-09-17 21:32:01 5320 [Note] InnoDB: Compressed tables use zlib 1.2.3 <CUT>
[18 Sep 2014 7:26]
Shahriyar Rzayev
The purpose of report is that,
Error log name is wrong in /etc/logrotate.d/mysql script which is installed by default after fresh install.
In any conditions there will be no such error log name as "/var/lib/mysql/mysqld.log"
As you stated it will be "/var/log/mysqld.log" file after fresh install.
But if you comment it you will have an error log file named as hostname.err and it will reside in datadir, again as you specified: "/var/lib/mysql/tikal.br.err"
So again as i show, the default installed and created rule for logrotation is wrong. Exactly the name of error log file:
/var/lib/mysql/mysqld.log {
# create 600 mysql mysql
notifempty
daily
rotate 5
missingok
compress
postrotate
# just if mysqld is really running
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin ping &>/dev/null
then
/usr/bin/mysqladmin flush-logs
fi
endscript
}
The second issue is about, using mysqladmin in logrotate script without password it will surely raise an error because there is no such server without root password :)
So the script named in source tree "/mysql-5.6.20/support-files/mysql-log-rotate.sh" is problematic.
[18 Sep 2014 12:25]
MySQL Verification Team
Indeed thank you for the feedback. Now changing status.
[15 Dec 2016 12:56]
Erlend Dahl
Fixed in 5.7.18, 8.0.1 under the heading of Bug#22322685 ERROR LOG DEFINED PATH MIS-ALIGNS WITH LOGROTATE.D CONFIG IN RPM INSTALL

Description: Dear experts, While reading Log Rotating in Linux i examine MySQL's logrotate script which is installed as default. The path in source code is: /mysql-5.6.20/support-files/mysql-log-rotate.sh And from spec file (/mysql-5.6.20/support-files/mysql.5.6.20.spec): # Install logrotate and autostart install -m 644 $MBD/release/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql After install you can verify that it is really installed on specified path: [root@linuxsrv2 logrotate.d]# ls /etc/logrotate.d cups dracut httpd mysql numad psacct sssd syslog yum Open up this file and you will see that default log file is: /var/lib/mysql/mysqld.log { # create 600 mysql mysql notifempty daily rotate 5 missingok compress postrotate # just if mysqld is really running if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin ping &>/dev/null then /usr/bin/mysqladmin flush-logs fi endscript } In fact there must not be such log file due following reasons: 1. After fresh install in default my.cnf file there is an entry for log-error: [mysqld_safe] log-error=/var/log/mysqld.log So the file name in fact is /var/log/mysqld.log 2. Official documentation states that: "Default log file name will be hostname.err and will reside in datadirectory if not specified explicitly". So the name of very end error log file will be: /var/lib/mysql/hostname.err. There is a second issue with this default rule in /etc/logrotate.d/mysql it is using mysqladmin without password it will raise an error: [root@linuxsrv2 logrotate.d]# logrotate -f mysql /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' error: error running non-shared postrotate script for /var/lib/mysql/linuxsrv2.err of '/var/lib/mysql/*.err ' How to repeat: Install MySQL 5.6.20 and look at default installed logrotate script at: /etc/logrotate.d/mysql Suggested fix: I think mysql-log-rotate.sh script should be topic of deprecating in next proposals. And not to install it as default. Instead of making such unclear rules and handle every aspect of error log name , passing root password in text file and etc, It is much more easier to write a Python script for this purpose and adding it to MySQL-Utilities package such everybody could run it from cron as easy as other things.