mysqlreplicationmysqlbinlog

Restoring purged mysql binlog files


I've got a replication set up on pair of servers. One is a master and second is a slave.

Recently on master the binlog files were purged too early (by filename so mysql haven't prevented too early removal of file).

Now the SLAVE has status:

Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'

I wan't to restore the missing binlog files so the slave will restart reading from the point it finished.

The files are already in place but how can I force master to 'unpurge' it's log list (so they are visible in SHOW BINARY LOGS)?


Solution

  • Ok I made it. However this solution isn't perfect/100% safe.

    I've entered all filenames to my mysql-bin.index

    find /var/log/mysql/ -wholename '/var/log/mysql/mysql-bin.0*' | sort > mysql-bin.index
    

    (if you will use it check the filename format in mysql-bin.index file first and adjust to your needs)

    Then restart mysql and mysql reloads that file on start.

    the MASTER is ready.

    Now it's enough to do

    SLAVE STOP;
    

    and

    SLAVE START;
    

    on SLAVE and it will continue his job.