Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22659

Create one single unified and optimal logrotate config

    XMLWordPrintable

    Details

      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:

      There are also multiple Jira issues:

      Also to be considered, that in systemd the logs go to journald and /var/log/mysql stays empty.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              otto Otto Kekäläinen
              Reporter:
              otto Otto Kekäläinen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: