2011/10/13

Restore Slave When it broke

When something goes wrong, slave throws error, one symptom will be that a lot of mysqld-relay-bin.xxxx files are accumulated in /var/lib/mysql/. So you try to restart slave, but got error,
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
And you check mysql error log (usually at /var/log/mysqld.log), it says "111014 3:30:47 [ERROR] Error reading slave log configuration". How to do? The simple solution is that,
  • Stop slave, by "slave stop;" at mysql command line.
  • Remove all mysqld-relay-bin.xxxx.
  • Remove master.info and relay-log.info
  • Then start slave by "slave start"
That should work, but you may lost some positions. And if you wanted to start slave at current replcate log file, then you can run one more command before starting slave.
CHANGE MASTER TO MASTER_LOG_FILE='your_current_replog.000693', MASTER_LOG_POS=certain_pos (I used 4);
Good luck!

No comments:

Post a Comment