logrotate mariadb 没有按预期工作

logrotate mariadb 没有按预期工作

我正在尝试为 mariadb 日志文件配置 logrotate,环境:

系统:RHEL 8.2
logrotate:3.14.0
mariadb:10.4

该文件是

/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

}

我尝试启动脚本时得到了此输出

[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

我得到了这个日志文件的结果,文件正在旋转,但是 mariadb 停止写入原始文件

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

我该怎么做才能修复这个问题?

答案1

您似乎已经修改了/etc/logrotate.d/mysqlMariaDB 附带的原始 logrotate 配置。它包含您需要遵循的说明,具体如下:

# 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 !

相关内容