Oussema Cherni bio photo

Oussema Cherni

Linux Systems engineer & Internet side-preneur From Tunisia

Twitter Google+ LinkedIn Instagram Github

Suite un crash serveur, il est possible que le relay log soit corrumpu ce qui casse la répilcation MySQL

mysql> show slave status\G;
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: xx.184.32.11
                Master_User: replicator
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.003306
        Read_Master_Log_Pos: 4367574
             Relay_Log_File: mysqld-relay-bin.002907
              Relay_Log_Pos: 784436
      Relay_Master_Log_File: mysql-bin.003306
           Slave_IO_Running: Yes
          Slave_SQL_Running: No
            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: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
               Skip_Counter: 0
        Exec_Master_Log_Pos: 2753840
            Relay_Log_Space: 1204554
            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
1 row in set (0.00 sec)

Sur le master xx.184.32.11, On doit vérifier si le Bin Log existe toujours.

Si c’est Ok, on note le Relay_Master_Log_File & le Exec_Master_Log_Pos

      Relay_Master_Log_File: mysql-bin.003306
      Exec_Master_Log_Pos: 2753840

Ensuite

mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

mysql> change master to master_log_file='mysql-bin.003306',master_log_pos=2753840;
Query OK, 0 rows affected (0.09 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

Normalement, vous devez avoir

mysql> show slave status\G;
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: xx.184.32.11
                Master_User: replicator
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.003306
        Read_Master_Log_Pos: 4496770
             Relay_Log_File: mysqld-relay-bin.001801
              Relay_Log_Pos: 541680
      Relay_Master_Log_File: mysql-bin.003306
           Slave_IO_Running: Yes
          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: 4496770
            Relay_Log_Space: 541680
            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: 0