该问题的一般是由relay log没有在配置文件定义所致。
1、问题描述:
mysql> start slave;
ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository
mysql> system perror 1872
MySQL error code 1872 (ER_SLAVE_RLI_INIT_REPOSITORY): Slave failed to initialize relay log info structure from the repository
2、处理办法
2.1、修改配置文件
诸如在my.cnf配置文件中添加如下项:
relay_log = /opt/mysql/logs/mysql-relay-bin
重启mysql实例使其生效。
2.2、重新连接master
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> change master to master_host='192.168.2.10',master_user='repl_user',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=821301;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> start slave;
ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository
重新连接后问题依旧。
2.3、重新设置slave
mysql> reset slave;
Query OK, 0 rows affected (0.00 sec)
mysql> change master to master_host='192.168.2.10',master_user='repl_user',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=821301;
Query OK, 0 rows affected, 2 warnings (0.02 sec)
mysql> start slave;
Query OK, 0 rows affected (0.12 sec)
再次查看slave状态:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.2.10
Master_User: repl_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 824989
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 3971
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
.......
问题解决。