今天由于 slave 机异常掉电导致主从同步出现异常
在 slave mysql 上查看 slave 状态:
show slave status\G
发现 IO 线程正常,但是 SQL 线程 NO,错误如下:
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.
查看 mysql 错误日志:
160817 18:01:14 [ERROR] Error in Log_event::read_log_event(): 'read error', data_len: 1011, event_type: 23
160817 18:01:14 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
160817 18:01:14 [ERROR] Slave SQL: 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. Error_code: 1594
160817 18:01:14 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000022' position 1068142925
We stopped at log ‘mysql-bin.000022’ position 1068142925
重新定位 master binlog
stop slave;
change master to master_host='172.16.18.114',master_user='root',master_password='cpyf', master_log_file='mysql-bin.000022',master_log_pos=1068142925;
start slave;
show slave status\G
SQL Thread 正常了。
应该是异常掉电导致 relay-log 错误导致的。