早上接到值班员的电话 说mysql 不同步了。
经查看发现机器早山无故断电了。
[root@twin14372 data]# uptime 07:54:00 up 38 min, 1 user, load average: 0.00, 0.01, 0.15
机房一天机器突然断电,导致slave损坏,报错如下:
[root@twin14372 ~]# mysql -u root -pb5fdb71d -e "show slave status\G" *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 123.150.185.190 Master_User: slave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000393 Read_Master_Log_Pos: 252376610 Relay_Log_File: relay-bin.000468 Relay_Log_Pos: 189083515 Relay_Master_Log_File: mysql-bin.000393 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: 1594 Last_Error: Relay log read failure: 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: 180112968 Relay_Log_Space: 264877714 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: 1594 Last_SQL_Error: Relay log read failure: 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.
值得注意:
Master_Log_File: mysql-bin.000393
Read_Master_Log_Pos: 252376610
Relay_Log_File: relay-bin.000468
Relay_Log_Pos: 189083515
Relay_Master_Log_File: mysql-bin.000393
………………………………
Exec_Master_Log_Pos: 180112968
Relay_Log_Space: 264877714
Until_Condition: None
记住红色标记的地方:
Master_Log_File: mysql-bin.000393
Exec_Master_Log_Pos: 180112968
解决办法:
mysql> stop slave; Query OK, 0 rows affected (0.00 sec) mysql> CHANGE MASTER TO MASTER_HOST='123.150.185.190', MASTER_PORT=3306, MASTER_USER='slave', MASTER_PASSWORD='b5fdb71d', MASTER_LOG_FILE='mysql-bin.000393', MASTER_LOG_POS=180112968; Query OK, 0 rows affected (0.09 sec) mysql> start slave; Query OK, 0 rows affected (0.00 sec)
ok了slave正常运行了
mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 123.150.185.190 Master_User: slave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000394 Read_Master_Log_Pos: 13922311 Relay_Log_File: relay-bin.000004 Relay_Log_Pos: 14615799 Relay_Master_Log_File: mysql-bin.000394 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: 13922311 Relay_Log_Space: 14615991 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: 1 row in set (0.00 sec)