Mysql – failed to sync slave with master

MySQL

Hi I have setup a mysql replication Master-slave using mysql utilities, my master have went down as the disk space of log file was full, then I chan ged the log file and started master now slave have stopped giving the error master disk full.

Now when I am trying to start mysql replication, it giving the following output. Please help me resolving this.

sudo mysqlreplicate --master=user:password@IPaddress:3306 --slave=user:password@IPaddress:3306 --rpl-user=user:password
WARNING: Using a password on the command line interface can be insecure.
# master on 10.0.0.1: ... connected.
# slave on 10.0.0.2: ... connected.
# Checking for binary logging on master...
# Setting up replication...
ERROR: failed to sync slave with master.
ERROR: Cannot setup replication.

This is the error in show slave status\G;

Last_IO_Errno: 1236 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event 'mysql-bin.000012' at 70361002, the last event read from '/app2/mysql/mysql-bin.000012' at 70361002, the last byte read from '/app2/mysql/mysql-bin.000012' at 70361088.' –

Best Answer

The Percona Blog has some information on dealing with this

— Got fatal error 1236 from master when reading data from binary log: ‘binlog truncated in the middle of event; consider out of disk space on master; the first event ‘mysql-bin.000525’ at 175770780, the last event read from ‘/data/mysql/repl/mysql-bin.000525’ at 175770780, the last byte read from ‘/data/mysql/repl/mysql-bin.000525′ at 175771648.’

Usually, this caused by sync_binlog <>1 on the master server which means binary log events may not be synchronized on the disk. There might be a committed SQL statement or row change (depending on your replication format) on the master that did not make it to the slave because the event is truncated. The solution would be to move the slave thread to the next available binary log and initialize slave thread with the first available position on binary log as below:

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000526', MASTER_LOG_POS=4;

I imagine you may lose some data doing this.