大网数据广告活动
服务器运维问答

logrotate mariadb not workin as expected

· 52CE 我爱测

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 max…

问题原文

原帖链接 · Hachem Bouhlel · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

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 !

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。