LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2011, 12:34 AM   #1
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Rep: Reputation: 0
Angry Log file rotation problem


Hi,

I am on a CentOS 64 bit and used webmin to rotate MySQL slow query log. Now the thing is although logs are being rotated daily but the new log files being created are empty which means MySQL is unable to write them due to some reason. I have checked using "ls -l" that both permission and owner of files is same but still MySQL is not writing logs. What could be the reason?

Thanks
 
Old 01-17-2011, 02:02 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

This usually means that mysqld was not restarted after the logs rotation, so the server still writes its logs in the old log file.

Regards
 
Old 01-17-2011, 02:59 AM   #3
Andy Alt
Member
 
Registered: Jun 2004
Location: Minnesota, USA
Distribution: Slackware64-stable, Manjaro, Debian64 stable
Posts: 528

Rep: Reputation: 167Reputation: 167
What bathory said.

As I understand it, if the log file is emptied by another program while mysql is running, mysql doesn't know about it, so gets confused.

In a few logrotate scripts, the daemon is restarted. Here's an example from my httpd logrotate script. (DO NOT copy and paste)

Code:
/var/log/httpd/*_log {
  rotate 10
  notifempty
  size=5M
  compress
  delaycompress
  sharedscripts
  postrotate
    /etc/rc.d/rc.httpd restart
  endscript
}
 
Old 01-17-2011, 03:47 AM   #4
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Original Poster
Rep: Reputation: 0
But shouldn't MySQL do it without restarting? I mean what if my site is heavy traffic and I want daily log rotation. So that means I will have to restart it daily!?
 
Old 01-17-2011, 03:59 AM   #5
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Ok I found out that you have to use "flush-logs" command to flush old logs and then MySQL creates a new one.

Quote:
shell> mysqladmin flush-logs
http://dev.mysql.com/doc/refman/5.0/...intenance.html

But why do I have to do it manually? Should webmin be doing this automatically when it runs that script to rotate log file?
 
Old 01-17-2011, 05:37 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
But why do I have to do it manually? Should webmin be doing this automatically when it runs that script to rotate log file?
I'm not using webmin, but I guess you have to configure the module that rotates the logs, to run "mysqladmin flush-logs" after logs rotation
 
Old 01-17-2011, 06:28 AM   #7
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
I'm not using webmin, but I guess you have to configure the module that rotates the logs, to run "mysqladmin flush-logs" after logs rotation
Oh yes there is an option in webmin through which you can run a command after log file is rotated. I completely missed it. Will try it and then see how it goes.
 
Old 01-21-2011, 12:47 AM   #8
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Original Poster
Rep: Reputation: 0
After observing a couple of days I see that the post rotation command option in webmin is not working. It is not running "mysqladmin flush-logs" command automatically after logs are rotated even though I have defined in it. When I run this command manually then it works.
 
Old 01-21-2011, 02:02 AM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Maybe you should give the full path to the command, like:
Code:
/usr/bin/mysqladmin flush-logs
or even add "-u root -p<password>"
 
Old 02-02-2011, 04:55 AM   #10
aliweb
LQ Newbie
 
Registered: Jan 2011
Posts: 9

Original Poster
Rep: Reputation: 0
Ok I tried the following in webmin but none of them works.

Code:
/usr/bin/mysqladmin flush-logs
Code:
/usr/bin/mysqladmin -u root -p<ROOT_PASSWORD> flush-logs
Code:
/usr/bin/mysqladmin -u <DB_USER> -p<DB_PASSWORD> flush-logs
 
Old 02-02-2011, 07:01 AM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Have a look here

Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
audit log rotation jnojr Linux - Security 4 06-02-2009 11:08 AM
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
Log Rotation for snort log does not seem to be working CentOS4.5 JasonKretzer Linux - Security 3 06-25-2007 12:25 PM
Webalizer With Log Rotation dmedici Linux - Software 0 08-17-2004 09:06 AM
manual log rotation will103 Linux - Newbie 2 04-20-2004 02:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration