mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_Running: No
Slave_SQL_Running: No
Last_SQL_Errno: 1872
Last_SQL_Error: Slave failed to initialize relay log info structure from the repository
MySQL的错误日志:error_slave.log
[Note] Slave: MTS group recovery relay log info based on Worker-Id 0, group_relay_log_name /data_3308/logs/relay_3308.000845, group_relay_log_pos 522379324 group_master_log_name mysql_bin_3308.000011, group_master_log_pos 1000899622
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000892908.
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000894934.
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000897596.
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000899622.
[Note] Slave: MTS group recovery relay log info based on Worker-Id 1, group_relay_log_name /data_3308/logs/relay_3308.000845, group_relay_log_pos 522377298 group_master_log_name mysql_bin_3308.000011, group_master_log_pos 1000897596
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000892908.
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000894934.
[Note] Slave: MTS group recovery relay log info group_master_log_name mysql_bin_3308.000011, event_master_log_pos 1000897596.
[ERROR] --relay-log-recovery cannot be executed when the slave was stopped with an error or killed in MTS mode;
consider using RESET SLAVE or restart the server with --relay-log-recovery = 0
followed by START SLAVE UNTIL SQL_AFTER_MTS_GAPS
[ERROR] Failed to initialize the master info structure
[Note] Check error log for additional messages. You will not be able to start replication until the issue is resolved and the server restarted.
relay_log_recovery 和slave_parallel_workers的参数设置
mysql> show variables where variable_name in ('slave_parallel_workers','relay_log_recovery');
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| relay_log_recovery | ON |
| slave_parallel_workers | 2 |
+------------------------+-------+
2 rows in set (0.03 sec)
my.cnf修改relay_log_recovery=0, 重启MySQL, start slave 恢复正常。
关于此错误的分析:
http://www.hustdba.com/?p=74
http://bugs.mysql.com/bug.php?id=72824 中给出的方法
reset slave all won't work, in my instance, I use the following method:
1) keep record of the info in Relay log info;(show slave status)
2) stop slave;
3) reset slave;
4) start slave;
5) stop slave;
6) change master to position recorded in step 1);
7) start slave
Description:
With slave_parallel_workers > 0 if the slave is restarted while the replication is stopped due to an error, it is not possible to get the replication running again.
Confirmed in 5.6.19 and 5.7.4.
是不是意味着MySQL在5.6.19 and 5.7.4 版本之间,如果slave_parallel_workers > 0同时relay_log_recovery设置为ON的话会有问题呢?
relay_log_recovery=ON
slave_parallel_workers=2
5.6的官方文档对relay-log-recovery的描述
http://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html#option_mysqld_relay-log-recovery
Prior to MySQL 5.6.6, if this option is enabled for a multi-threaded slave, and the slave fails with errors,
you cannot execute CHANGE MASTER TO on that slave. In MySQL 5.6.6 or later,
you can use START SLAVE UNTIL SQL_AFTER_MTS_GAPS to ensure that any gaps in the relay log are processed;
after running this statement, you can then use CHANGE MASTER TO to fail this slave over to a new master. (Bug #13893363)