Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How to measure MySQL replication delay between 2 MySQL servers ( 1 Master 1 Slave ) ?

Given that two Xeon E5620 grade 1U servers are separate machine in same network segment, using MySQL Community Server 5.1 running in Ubuntu Linux Server 11.04.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

In MySQL command line, give command

SHOW SLAVE STATUS\G

and see the Seconds_behind_ master value.

Or if you want to script that somehow, the one-liner below returns how many seconds behind master the slave currently is.

mysql -u your_user -e 'SHOW SLAVE STATUS\G' | grep "Seconds_Behi" | awk '{ print $2; }'
share|improve this answer
    
Cool. May I ask what does the \G mean? –  Raptor Nov 28 '11 at 14:00
1  
\G formats the status command output in more human-readable way and in this case makes the grep part easier, too. :) In other words, \G puts each status entry in its own line, without it you get a messy table-like output with ascii graphics and all. –  Janne Pikkarainen Nov 28 '11 at 14:02

I guess it depends how accurate you want to be and for what purpose.

I update a record on the master and then do several reads from the slave until I get the updated record. I'm working with a slow connection between the two seperate offices. So 0.1 second resolution is good enough for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.