Error 1593 en Mysql Slave

mysql replication

El Error 1593 de mysql es debido a la corrupción del archivo de replicación. 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 1593.

Dentro de nuestro mysql esclavo podemos ejecutar:

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 149.204.94.204
Master_User: esclavo
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mariadb-bin.010340
Read_Master_Log_Pos: 87106259
Relay_Log_File: relay-bin.000209
Relay_Log_Pos: 11410385
Relay_Master_Log_File: mariadb-bin.010323
Slave_IO_Running: No
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: 1593
Last_Error: Error initializing relay log position: I/O error reading event at position 4
Skip_Counter: 1
Exec_Master_Log_Pos: 11410096
Relay_Log_Space: 1872973112
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: 0
Last_IO_Error:
Last_SQL_Errno: 1593
Last_SQL_Error: Error initializing relay log position: I/O error reading event at position 4
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
1 row in set (0.00 sec)

Para solucionarlo, primero tomaremos nota de los valores:

Relay_Master_Log_File: mariadb-bin.010323
Exec_Master_Log_Pos: 11410096

Para solucionar éste error, tenemos que parar el esclavo y resetearlo. Luego coger de nuevo el archivo de logs y resincronizar el mysql esclavo con el maestro:

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

MariaDB [(none)]> reset slave all;
Query OK, 0 rows affected (0.14 sec)

MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST=’ip_maestro’, MASTER_USER=’usuario_master’, MASTER_PASSWORD=’master_password’, MASTER_LOG_FILE=»mariadb-bin.010323', MASTER_LOG_POS=11410096;
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.

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?