1
votes

I have a Master to Master replication set up between two MySQL 5.0

My requirement is that before starting my application I have to ensure that the database are identical I would like to confirm that the "seconds_behind_master" of the "show slave status" command being at 0 seconds is enough to consider the 2 databases being synchronized ?

http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html

Thank you

2
Are you only writing to one database? If not, is your data at all dependent on the order of inserts (think autoincrement fields)? - Marcus Adams
No the data is not dependent on the order of the inserts and we have set one server to auto_increment only odd numbers and the other even to avoid replication conflicts and reconciliation. - Stainedart

2 Answers

1
votes

No, that is not sufficient to guarantee that the databases are identical, just that the slave has run all statements from the master's binary log. You could update or delete large chunks of data on the slave database and still have seconds behind master = 0, but the slave would certainly not be identical to the master.

You should use a tool like Percona's pt-table-checksum if you really want to verify that the databases are identical.

1
votes

It's not really a guarantee, as master-to-master replication does not guarantee atomicity across servers.

Also, a single read of 0 could be meaningless, but a consistent read of 0 over time would be a good indication that the servers are synced, if you have no errors reported.

So, I say, read it every second for 10 seconds, and if they're all 0, with no errors, you're probably good enough, short of comparing checksums, as Ike suggested.