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.

link|improve this question

feedback

2 Answers

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; }'
link|improve this answer
Cool. May I ask what does the \G mean? – Shivan 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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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