How To Clear Mysql Log File In Linux
- Home
- Linux
- General Linux
I'm using a MediaWiki server and we had some issues with our banner script and a few other items. Eventually I traced it back to the server running out of space, and 95% of that space is consumed by the mysql.log file.
I didn't want to remove it without doing some research first, however I can't seem to find references to it on MediaWiki's site so I figure it is strictly a MySQL database issue.
So, here are my questions:
Is the mysql.log needed?
Is there a simple way to truncate it, or can it just be deleted and a new one will take its place?
(mv mysql.log mysql.old && mysqladmin flush-logs)?
Can the log file size be limited to avoid this issue in the future?
If it's the "General Query Log," that is disabled by default, so you can probably safely disable. You can tweak it so that it only logs commits and/or exclude logging for specific statements. .
https://mariadb.com/kb/en/library/general-query-log/
- ROM
- CPU
- RAM
- GPU
8 Replies
See what is being logged. Fix the error, if need be.
Or maybe logging is set to a verbose level and you can safely take it down a notch or two.
I don't think renaming the log file will be helpful, as the file will still be opened for writing.
You could redirect /dev/null to log to zero it out, but don't do that until you understand what is being logged.
If you have another filesystem with more space available, you could copy the log to the other filesystem, remove if from the original location (mv will do this in 1 step), then symlink back to the original location. You'd want to stop mysqld before doing this.
When I looked inside it seemed to just be queries from the wiki being used, so I imagine it is just a history log.
I plan to do maintenance tonight to figure it out. Stopping mysql, copying the file off, and seeing if it starts okay is going to be the start of it. I'm mostly curious to know more about it and to avoid the issue in the future.
If it's the "General Query Log," that is disabled by default, so you can probably safely disable. You can tweak it so that it only logs commits and/or exclude logging for specific statements. .
https://mariadb.com/kb/en/library/general-query-log/
As this is a *nix environment and that log is the standard mysql log file, if you move the file, truncate the log or edit its configuration file you should tell the mysqld daemon to re-read it. That may happen by design, but if you want to be sure it has happened. The standard Unix concept is to send the HUP signal to the related service. I believe this would be enough to cause the deamon to close the open and re-open a file descriptor.
When dealing with Linux, I use "service mysqld reload" from the command line.
Putting your logs on a different partition will help with not filling up the main disk. It should stop major problems like the site going down
Is it filling up over multiple days? or in hours?
As pointed out above
1 - find the issue that's making massive log files and fix it
2 - add that log file to the group of files rotated by the operating system - often /etc/logrotate.conf and /etc/logrotate.d/ or similar depending on distribution
3 - consider moving your logs to a separate partition, so the system will run regardless
From what I read that file shouldn't be touched while mysql is using it. I got it taken care of last night and disabled the general log since it isn't something we actively use, I'm thinking it was enabled for some troubleshooting and never turned back off.
pigdog wrote:
If it's the "General Query Log," that is disabled by default, so you can probably safely disable. You can tweak it so that it only logs commits and/or exclude logging for specific statements. .
https://mariadb.com/kb/en/library/general-query-log/
I'm using mysql but the same logic helped. I was able to get the log moved off and disabled the logging. I'm guessing it was enabled at some point for troubleshooting and never turned back off. Thanks!
This topic has been locked by an administrator and is no longer open for commenting.
To continue this discussion, please ask a new question.
How To Clear Mysql Log File In Linux
Source: https://community.spiceworks.com/topic/2213728-how-would-you-handle-a-large-mysql-log-file-filling-up-a-linux-server
Posted by: phillipsnursucher.blogspot.com
0 Response to "How To Clear Mysql Log File In Linux"
Post a Comment