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
}
我得到了這個輸出trynig來啟動腳本
[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
我能做些什麼來解決這個問題?
您似乎已在
/etc/logrotate.d/mysql
此處修改了 MariaDB 隨附的原始 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 !