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