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.

I'm having a master/slave mysql setup. This night I had some problems with the master. I needed to recreate all databases again because they were corrupt.

Now I stopped my mysql slave but want to start it again and rebuild everything from scratch. Is there a way to do this? Without locking the master...

I also think the binlog file should be reset. So everything is clean again.

Any ideas?

share|improve this question
    
add comment

2 Answers

up vote 3 down vote accepted

if you use innodb engine on the master - just use mysqldump with --skip-lock-tables, --single-transaction and --master-data=2 switches.

if your slave is only logically corrupted - try pt-table-sync with lock=0 option

share|improve this answer
    
If I set the master-data to 2 the change master query is put in comment. But how about the pointer in the binlog? And should I reset the binlog? –  Ward Loockx Sep 1 '12 at 9:37
    
you can set it to 1 to get it uncommented. i prefer to get have --master-data=2 and later - when i'm ready copy & paste the CHANGE MASTER TO to the mysql command line on a slave. dont reset binlog on master; i assume your slave will be a clean slate - so there's no need of resetting anything there. just reload the dump, issue CHANGE MASTER TO and include address and credentials of master host. –  pQd Sep 1 '12 at 9:42
    
Currently the slave is already configured, I just did STOP SLAVE. So I just need to import the new dump and that's it ? –  Ward Loockx Sep 1 '12 at 9:43
    
ok - so import new dump on slave; it'll drop all existing databases anyway. then issue CHANGE MASTER TO.. and SLAVE START. then check SHOW SLAVE STATUS\G. for a good measure run pt-table-checksum to make sure all is in sync. –  pQd Sep 1 '12 at 9:44
add comment

Follow this:

  • Disconnect slave and master
  • Just drop all databases from slave
  • dump data from master with single-transaction
  • use dump on slave
  • reconnect master and slave, and wait for sync-ing
share|improve this answer
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.