MySQL Replication – Setting Up Master-Slave Replication

MySQLreplication

I have a setup of two databases, master – slave.
Slave was stooped for about two weeks and old binlogs binlogs purged from master but copied on another fs before purging.

Slave can't catch up the master because index don't contain anymore the names of the purged binlogs.

I've already copied old binlogs to the correct place but now I need to edit the .index file on master.

Is there a tool that can be used to tell mysql too add binary logs back to index files (somethinf like unpurge 🙂 or add binary log) or can index file be edited without shutting down mysql ?

Thanks a lot.

Best Answer

The bin log index file can be edited with the binlog file names without restarting the mysqld server.

Although after restoring the files back to the binlog location, you may want to make sure that the files you copied have same ownership and permissions for mysqld user to access those.

steps: 1:- determine the location where your bin logs are stored. you can get the location from "/etc/my.cnf" , which i believe you are already aware of. 2:- copy the backups to the location, which i believe you have already done. 3:- Edit the indexfile 4:- add a line above for each file. 5:- update the permissions and ownership -- chown mysql:mysql filename (assuming you are running with user mysql) 5:- show binary logs

Note you may want to keep the slave off while making changes and start slave once all files are showing on the mysql client.