1

i'm trying to configure logrotate for mariadb log files, Environment:

system : RHEL 8.2
logrotate : 3.14.0
mariadb: 10.4

the file is

/var/lib/mysql/SITE2-L-MANAGEDPKI-01.log{
    missingok
    notifempty
    copytruncate
    daily
    minsize 1M
    maxsize 1G
    rotate 10
    dateext
    dateformat .%Y-%m-%d
    compress
    delaycompress
    sharedscripts
postrotate
    # just if mysqld is really running
    if test -x /usr/bin/mysqladmin && \
       env HOME=/root/ /usr/bin/mysqladmin ping &>/dev/null
    then
       /usr/bin/mysqladmin --local flush-error-log \
          flush-engine-log flush-general-log flush-slow-log
    fi
endscript

}

i got this output trynig to start the script

[root@SITE2-L-MANAGEDPKI-01 mysql]# logrotate --force /etc/logrotate.d/mariadb


/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
error: error running shared postrotate script for '/var/lib/mysql/SITE1-L-MANAGEDPKI-01.log

and i got this log files result, the file is rotating but mariadb stop writing into original file

1.9M    SITE2-L-MANAGEDPKI-01.ERR
0       SITE2-L-MANAGEDPKI-01.log
247M    SITE2-L-MANAGEDPKI-01.log.2020-06-18

what i can do to fix this?

1 Answers1

1

You seem to have modified the original logrotate config /etc/logrotate.d/mysql that was shipped with MariaDB here. It contains instructions that you need to follow, specifically:

# This logname can be set in /etc/my.cnf
# by setting the variable "log-error"
# in the [mysqld] section as follows:
#
# [mysqld]
# log-error=/var/lib/mysql/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 !
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940