2013-01-10 17:35:12 +00:00
|
|
|
|
Adjust the mysql-log-rotate script in several ways:
|
|
|
|
|
|
|
|
|
|
* Use the correct log file pathname for Red Hat installations.
|
|
|
|
|
* Enable creation of the log file by logrotate (needed since
|
|
|
|
|
/var/log/ isn't writable by mysql user); and set the same 640
|
|
|
|
|
permissions we normally use.
|
|
|
|
|
* Comment out the actual rotation commands, so that user must edit
|
|
|
|
|
the file to enable rotation. This is unfortunate, but the fact
|
|
|
|
|
that the script will probably fail without manual configuration
|
|
|
|
|
(to set a root password) means that we can't really have it turned
|
|
|
|
|
on by default. Fortunately, in most configurations the log file
|
|
|
|
|
is low-volume and so rotation is not critical functionality.
|
|
|
|
|
|
|
|
|
|
See discussions at RH bugs 799735, 547007
|
2017-05-23 13:14:48 +00:00
|
|
|
|
* Note they are from Fedora 15 / 16
|
|
|
|
|
|
|
|
|
|
Update 3/2017
|
|
|
|
|
* it would be big unexpected change for anyone upgrading, if we start shipping it now.
|
|
|
|
|
Maybe it is good candidate for shipping with MariaDB 10.2 ?
|
|
|
|
|
* the 'mysqladmin flush logs' doesn´t guarantee, no entries are lost
|
|
|
|
|
during flushing, the operation is not atomic.
|
|
|
|
|
We should not ship it in that state
|
2013-01-10 17:35:12 +00:00
|
|
|
|
|
2018-06-27 14:01:22 +00:00
|
|
|
|
Update 6/2018
|
|
|
|
|
* the SIGHUP causes server to flush all logs. No password admin needed, the only constraint is
|
|
|
|
|
beeing able to send the SIGHUP to the process and read the mysqld pid file, which root can.
|
2018-06-29 00:21:45 +00:00
|
|
|
|
* Submited as PR: https://github.com/MariaDB/server/pull/807
|
2018-06-27 14:01:22 +00:00
|
|
|
|
|
2021-02-12 07:45:05 +00:00
|
|
|
|
Update 02/2021
|
|
|
|
|
* Enhance the script as proposed in:
|
|
|
|
|
https://mariadb.com/kb/en/rotating-logs-on-unix-and-linux/
|
|
|
|
|
* Discussion continues in:
|
|
|
|
|
https://jira.mariadb.org/browse/MDEV-16621
|
|
|
|
|
|
2022-02-22 04:03:33 +00:00
|
|
|
|
--- mariadb-10.5.13-downstream_modified/support-files/mysql-log-rotate.sh 2022-02-22 04:56:35.571185622 +0100
|
|
|
|
|
+++ mariadb-10.5.13-downstream_modified/support-files/mysql-log-rotate.sh_patched 2022-02-22 04:56:15.121003580 +0100
|
|
|
|
|
@@ -3,36 +3,23 @@
|
2019-12-06 13:55:29 +00:00
|
|
|
|
# in the [mysqld] section as follows:
|
2013-01-10 17:35:12 +00:00
|
|
|
|
#
|
2019-12-06 13:55:29 +00:00
|
|
|
|
# [mysqld]
|
|
|
|
|
-# log-error=@localstatedir@/mysqld.log
|
2018-06-27 14:01:22 +00:00
|
|
|
|
-#
|
|
|
|
|
-# 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 !
|
2019-12-06 13:55:29 +00:00
|
|
|
|
+# log-error=@LOG_LOCATION@
|
2013-01-10 17:35:12 +00:00
|
|
|
|
|
|
|
|
|
-@localstatedir@/mysqld.log {
|
|
|
|
|
- # create 600 mysql mysql
|
2018-06-27 14:01:22 +00:00
|
|
|
|
+@LOG_LOCATION@ {
|
|
|
|
|
+ create 600 mysql mysql
|
2022-02-22 04:03:33 +00:00
|
|
|
|
su mysql mysql
|
2018-06-27 14:01:22 +00:00
|
|
|
|
notifempty
|
2019-12-06 13:55:29 +00:00
|
|
|
|
daily
|
2018-06-27 14:01:22 +00:00
|
|
|
|
rotate 3
|
2021-02-12 07:45:05 +00:00
|
|
|
|
missingok
|
2018-06-27 14:01:22 +00:00
|
|
|
|
compress
|
2021-02-12 07:45:05 +00:00
|
|
|
|
+ delaycompress
|
|
|
|
|
+ sharedscripts
|
2018-06-27 14:01:22 +00:00
|
|
|
|
postrotate
|
2021-02-12 07:45:05 +00:00
|
|
|
|
# just if mariadbd is really running
|
2013-01-10 17:35:12 +00:00
|
|
|
|
- if test -x @bindir@/mysqladmin && \
|
|
|
|
|
- @bindir@/mysqladmin ping &>/dev/null
|
|
|
|
|
- then
|
2017-05-24 09:25:52 +00:00
|
|
|
|
- @bindir@/mysqladmin --local flush-error-log \
|
|
|
|
|
- flush-engine-log flush-general-log flush-slow-log
|
2013-01-10 17:35:12 +00:00
|
|
|
|
- fi
|
2018-06-27 14:01:22 +00:00
|
|
|
|
+ if [ -e @PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid ]
|
|
|
|
|
+ then
|
|
|
|
|
+ kill -1 $(<@PID_FILE_DIR@/@DAEMON_NO_PREFIX@.pid)
|
|
|
|
|
+ fi
|
|
|
|
|
endscript
|
|
|
|
|
}
|