4

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

1
  • 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, 2011 at 0:19

2 Answers 2

6

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

0
0

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.

4
  • 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, 2011 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, 2011 at 5:19
  • when synced; if the max size is filled; will it automatically jump to the next file?
    – Mike
    Jan 21, 2011 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, 2011 at 8:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .