Thesql slave replication doesn’t work due to error 1236

MySQLreplication

My mysql master server has crashed due to storage issue. The issue has been fixed and the master is up and running. However, my slave has stopped to be replicated due to the error:
Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'

Here is my slave status:

    mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.x.x.x
                  Master_User: user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000321
          Read_Master_Log_Pos: 3962375
               Relay_Log_File: mysql-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000321
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 3962375
              Relay_Log_Space: 106
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
               Last_SQL_Errno: 0
               Last_SQL_Error: 

And here is my master status:

mysql> show master status\G;
*************************** 1. row ***************************
            File: mysql-bin.000323
        Position: 103145634
    Binlog_Do_DB: 
Binlog_Ignore_DB: 
1 row in set (0.00 sec)

I can see that the specific binary log (mysql-bin.000321) doesn't exist on the master. The the log file itself exist on the server, but ain't shown by SHOW BINARY LOGS;.

mysql> SHOW BINARY LOGS;
+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000314 | 1073742675 |
| mysql-bin.000315 | 1073742958 |
| mysql-bin.000316 | 1073742098 |
| mysql-bin.000317 |  631008456 |
| mysql-bin.000318 |   18007666 |
| mysql-bin.000319 |        125 |
| mysql-bin.000320 |  327413876 |
| mysql-bin.000322 |        125 |
| mysql-bin.000323 |  109150417 |
+------------------+------------+

Please advise.

Best Answer

Sounds like this sequence happened:

  1. The slave went down, but you did not notice it.
  2. A few days(?) went by.
  3. The binlogs (on the Master) were automatically purged (either by a script you use, or by expire_logs_days)
  4. Now you noticed the Slave was stopped, but it is too late.

If this is not the only slave, stop another slave and clone it to rebuild this one.

If it is the only slave, you are stuck with rebuilding the slave from the master. Not fun.

But... You said the Master died and was repaired?? Well, look at the timeframes, and other things that I suggest above. How many days (#2); how fast is the purging (#3), etc?