Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.5
-
None
Description
Currently we have in 10.5 master two logrotate files:
$ cat support-files/mysql-log-rotate.sh
|
# This logname can be set in /etc/my.cnf
|
# by setting the variable "log-error"
|
# in the [mysqld] section as follows:
|
#
|
# [mysqld]
|
# log-error=@localstatedir@/mysqld.log
|
#
|
# If the root user has a password you have to create a
|
# /root/.my.cnf configuration file with the following
|
# content:
|
#
|
# [mysqladmin]
|
# password = <secret>
|
# user= root
|
#
|
# where "<secret>" is the password.
|
#
|
# ATTENTION: This /root/.my.cnf should be readable ONLY
|
# for root !
|
|
@localstatedir@/mysqld.log {
|
# create 600 mysql mysql
|
notifempty
|
daily
|
rotate 3
|
missingok
|
compress
|
postrotate
|
# just if mysqld is really running
|
if test -x @bindir@/mysqladmin && \
|
@bindir@/mysqladmin ping &>/dev/null
|
then
|
@bindir@/mysqladmin --local flush-error-log \
|
flush-engine-log flush-general-log flush-slow-log
|
fi
|
endscript
|
}
|
|
$ cat debian/mariadb-server-10.5.mysql-server.logrotate
|
# - I put everything in one block and added sharedscripts, so that mysql gets
|
# flush-logs'd only once.
|
# Else the binary logs would automatically increase by n times every day.
|
# - The error log is obsolete, messages go to syslog now.
|
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log {
|
daily
|
rotate 7
|
missingok
|
create 640 mysql adm
|
compress
|
sharedscripts
|
postrotate
|
test -x /usr/bin/mysqladmin || exit 0
|
if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then
|
# If this fails, check debian.conf!
|
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
|
flush-engine-log flush-general-log flush-slow-log
|
fi
|
endscript
|
}
|
I suggest we in future would have only one single mariadb.logrotate(.sh) file that would be used in all distros, both deb and rpm based. There is after all only one logrotate utility and the mariadbd responds to system signals the same way across all distros, and the mariadb-admin etc tools also work close enough on all distros.
I suggest we use the name 'mariadb' from now on, since the binary is 'mariadbd' from 10.5 onwards. Also I suggest we always use 'logrotate' and not 'log-rotate' in filenames, since the name of the utility is 'logrotate'.
There are currently open 2 PRs on fixing this script:
- https://github.com/MariaDB/server/pull/807 (rpm version fixes)
- https://github.com/MariaDB/server/pull/934 (deb version fixes)
There are also multiple Jira issues:
- https://jira.mariadb.org/browse/MDEV-11884 (Status 'Closed', but wasn't actually fixed by Ondrej in upstream) - deb version, upstreaming of this in PR#934
- https://jira.mariadb.org/browse/MDEV-13050 - deb version, also fixed in PR#934)
- https://jira.mariadb.org/browse/MDEV-16621 - delaycompress and sighup suggestions
- https://jira.mariadb.org/browse/MDEV-16772 - deb version, duplicate pid result fixed in PR#934
- https://jira.mariadb.org/browse/MDEV-19436 - deb version, duplicate of duplicate pid issue
- https://jira.mariadb.org/browse/MDEV-20863 - deb version, duplicate of duplicate pid issue
Also to be considered, that in systemd the logs go to journald and /var/log/mysql stays empty.
Attachments
Issue Links
- includes
-
MDEV-11884 Logrotate fails if mysqld is not running (logrotate_script: 3: [: /var/run/mysqld/mysqld.pid: unexpected operator)
- Closed
-
MDEV-13050 server/debian/mariadb-server-10.x.mysql-server.logrotate || GNU grep v. 2.2.4 [UBUNTU-16.04] FAILS
- Closed
-
MDEV-16621 Fix logrotate script
- Closed
-
MDEV-16772 mysql-server logrotate script does not flush logs
- Closed
-
MDEV-19436 Fix logrotate problem with twice configured pid-file option
- Closed
-
MDEV-20863 debian logrotate errors
- Closed
- is duplicated by
-
MDEV-25966 logrotate config files are not renamed to mariadb
- Closed