Investigating disk space issues on our Nagios VM revealed a myslqd.log file with the size of 25GB. The log file has been growing since the server was setup in 2016.
Is there anyway to enable logrotation for the myslqd.log file? So it is saved in a new file every month or week, and files of x age be deleted.
If it isn't already possible, can I make this as a feature request?
Logrotate for myslqd.log
Re: Logrotate for myslqd.log
You should already have a logrotate script in the "/etc/logrotate.d/" directory, named "mysqld". Open it in a text editor, and comment out the section on the bottom:
Change any options that you need to, e.g. "daily" to "weekly", etc.
In the "/etc/my.cnf" file, you would need to add a username/password, e.g:
You can test the log rotation by running:
Code: Select all
/var/log/mysqld.log {
create 640 mysql mysql
notifempty
daily
rotate 3
missingok
compress
postrotate
# just if mysqld is really running
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin ping &>/dev/null
then
/usr/bin/mysqladmin flush-logs
fi
endscript
}In the "/etc/my.cnf" file, you would need to add a username/password, e.g:
Code: Select all
[mysqladmin]
password = nagiosxi
user= rootCode: Select all
logrotate -f /etc/logrotate.d/mysqldBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Logrotate for myslqd.log
Ok, I have set it up like you suggested.
Thanks.
Just confused as to why this isn't standard on the NagiosXI VM.
Thanks.
Just confused as to why this isn't standard on the NagiosXI VM.
Re: Logrotate for myslqd.log
I am glad I could help!Ok, I have set it up like you suggested.
Thanks.
It's a good question - I will discuss it with our developers.Just confused as to why this isn't standard on the NagiosXI VM.
I will be closing this topic now. If you have any further issues/questions, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!