Error 1236 en Mysql Master Slave

mysql-master-slave-replication-1

El Error 1236 de mysql es debido a la corrupción del archivo de replicación en el master. Normalmente ésto sucede después de una caída total de server por algún problema de hardware, como fallos en la alimentación del servidor o cualquier otro problema de hardware que provoque la caída repentina de la máquina.

Al reiniciar el servidor esclavo mysql, despues de una inesperada caída, fácilmente tendremos un error de replicación 1236.

Dentro de nuestro mysql esclavo podemos ejecutar:

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 37.187.149.102
Master_User: esclavo
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mariadb-bin.000142
Read_Master_Log_Pos: 328
Relay_Log_File: relay-bin.000399
Relay_Log_Pos: 617
Relay_Master_Log_File: mariadb-bin.000142
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: 328
Relay_Log_Space: 1277
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: ‘bogus data in log event; the first event ‘mariadb-bin.000140’ at 54204313, the last event read from ‘mariadb-bin.000142’ at 328, the last byte read from ‘mariadb-bin.000142′ at 347.’
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
1 row in set (0.00 sec)

Para solucionarlo, primero tomaremos nota del archivo que no se puede leer correctamente:

Relay_Master_Log_File: mariadb-bin.000142

Para solucionar éste error, tenemos que parar el esclavo. Luego coger el siguiente archivo de logs válido (mariadb-bin.000143) y resincronizar el mysql esclavo con el maestro:

MariaDB [(none)]> stop slave;
Query OK, 0 rows affected (0.13 sec)

MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST=’ip_maestro’, MASTER_USER=’usuario_master’, MASTER_PASSWORD=’master_password’, MASTER_LOG_FILE==’mariadb-bin.000143′ ,MASTER_LOG_POS=0;
Query OK, 0 rows affected (0.11 sec)

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

Una vez que el esclavo empieza a funcionar, veremos que empieza a sincronizar sin errores y el tiempo entre el master y el slave irá decreciendo hasta llegar a cero

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 149.204.94.204
Master_User: esclavo
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mariadb-bin.000200
Read_Master_Log_Pos: 10822105
Relay_Log_File: relay-bin.000052
Relay_Log_Pos: 10822394
Relay_Master_Log_File: mariadb-bin.000200
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: 10822105
Relay_Log_Space: 10823054
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
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
1 row in set (0.00 sec)

Si todo ha ido correctamente en poco tiempo volveremos a tener:

Seconds_Behind_Master: 0

Que es el tiempo de delay entre el master y nuestro esclavo.

Con ésto quedará resincronizado nuestra replicación máster-slave en mysql.

Esta web utiliza cookies propias para su correcto funcionamiento. Al hacer clic en el botón Aceptar, aceptas el uso de estas tecnologías y el procesamiento de tus datos para estos propósitos. Más información
Privacidad
Abrir chat
¿Podemos ayudarte?