MySQL主从报错1872 Slave failed to initialize relay log info structure from the repository【原创】
一台MySQL服务器重启后发现主从复制报错
Last_Errno: 1872
Last_Error: Slave failed to initialize relay log info structure from the repository
mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Master_Host: X.X.X.X Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000076 Read_Master_Log_Pos: 828924371 Relay_Log_File: localhost-relay-bin.000188 Relay_Log_Pos: 720496744 Relay_Master_Log_File: mysql-bin.000076 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: 1872 Last_Error: Slave failed to initialize relay log info structure from the repository Skip_Counter: 0 Exec_Master_Log_Pos: 828924371 Relay_Log_Space: 0 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: 1872 Last_SQL_Error: Slave failed to initialize relay log info structure from the repository Replicate_Ignore_Server_Ids: Master_Server_Id: 0 Master_UUID: 54481e1e-99ad-11e5-8540-000af78d3c6c Master_Info_File: /home/mysql/mysql-data/mysql/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 210907 15:32:42 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: 1 row in set (0.00 sec) ERROR: No query specified
应该是服务器的主机名改过,relay-log也没有命名写在配置文件中。所以造成无法找到中继日志。
如果不命名会以主机名命名relay-log即
主机名-relay-bin.000001
解决办法:
可以在my.cnf指定中继日志名字,然后重启一下MySQL服务即可。
# cat /etc/my.cnf |grep relay relay-log=db1-relay-bin
欢迎转载,请注明出处!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?