MySQL Forums
Forum List  »  MySQL Administrator

Re: binlog file deleted accidentally
Posted by: Scott Nemes
Date: August 15, 2012 06:37PM

Close, but you'll need additional steps.

On the MASTER:

1) mysql> FLUSH TABLES WITH READ LOCK;
2) mysql> SHOW MASTER STATUS;
3) Write down the "File" (i.e. mysql-bin.000003) and "Position" (i.e. 73) from the above step.
4) NOTE: if you exit the mysql client session where you locked the tables (step #2), MySQL will release the locks, which you do not want. So you must run the mysqldump from a separate shell window and leave the other mysql client connection running. So in a separate window, run:

mysqldump --user=youruser -p --database mydatabase > ~/mydatabasebackup.sql

Once the dump is complete, go back to your original mysql client connection (where you locked the tables) for the next step.

5) mysql> UNLOCK TABLES;



The above steps place the backup in your home directory (~/). You will then need to copy that backup to the slave. The below steps assume the backup on the slave is again in your home directory (~/).



On the SLAVE:

6) mysql> STOP SLAVE; (should be unnecessary since it's already stopped due to missing binlogs, but just in case)
7) mysql --user=youruser -p mydatabase < ~/mydatabasebackup.sql
8) mysql> CHANGE MASTER TO MASTER_HOST='yourhost',
MASTER_USER='replicationuser',
MASTER_PASSWORD='replicationuserpassword',
MASTER_PORT=3306,
MASTER_LOG_FILE='file name from step #3',
MASTER_LOG_POS=position from step #3;

Example statement (using example data from step #3):

CHANGE MASTER TO MASTER_HOST='db1',
MASTER_USER='rep_user',
MASTER_PASSWORD='rep_password',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000003',
MASTER_LOG_POS=73;

9) mysql> START SLAVE;

If all goes well, your slave should then start catching up to the master. If you have any issues let me know.

--
Scott Nemes
MySQL DBA

http://www.linkedin.com/in/scottnemes
http://www.twitter.com/ScottNemes



Edited 1 time(s). Last edit at 08/15/2012 06:39PM by Scott Nemes.

Options: ReplyQuote


Subject
Written By
Posted
Re: binlog file deleted accidentally
August 15, 2012 06:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.