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

MySQL - If slave is offline for a few hours and comes back online, does it automatically catch data from master?

share|improve this question
    
One of my slave server was offline for a few hours and I brought it back up shortly ago, I noticed that the binlog pos #'s matched; but I thought if a slave server goes offline it looses sync? It looks like the data matched too, but I can't tell (20k+ rows) –  Mike Jan 20 '11 at 0:19
add comment

2 Answers 2

up vote 5 down vote accepted

In MySQL replication, a slave "syncs" its data from the master's transaction log, not directly from the database. The slave stores the last position in that transaction log, so as long as you have not touched that position number on the slave, then as soon as it becomes active again, it will resume executing transactions from that position it left off at. All should be well for you.

Here you go, for your reference:
http://dev.mysql.com/doc/refman/5.0/en/replication-implementation.html

share|improve this answer
    
Beautiful, thank you –  Mike Jan 20 '11 at 2:10
add comment

yes - however if the master bin log has changed the slave will not be able catch it. the slave keeps track of the bin log file where the master is and the position.

you can check on master

show master status;

on the slave

show slave status;

see if they use the same log file and note the position of the master versus slave. if there are some duplicates into the slave you can always skip records.

share|improve this answer
    
This i'm aware of; but what i'm not aware of is, when could the master ever change it's log? –  Mike Jan 20 '11 at 2:37
    
it depends by the max size you set. if for example you have a max size of 500 MB after it fills a file will start a new log. –  silviud Jan 20 '11 at 5:19
    
when synced; if the max size is filled; will it automatically jump to the next file? –  Mike Jan 21 '11 at 4:05
    
yes during normal operations the slave will change the log file. there is a way you can make the slave work as well if you have the binlogs - this is when the slave is way out if sync. –  silviud Jan 21 '11 at 8:49
add comment

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.