1

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.

Raptor
  • 991
  • 3
  • 16
  • 36

2 Answers2

4

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; }'
Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • 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
0

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.

Jaydee
  • 371
  • 3
  • 11