美文网首页Mysql
Mysql主从库不同步1236错误:could not find

Mysql主从库不同步1236错误:could not find

作者: 漫画三毛 | 来源:发表于2022-07-26 13:40 被阅读0次

文章来自:Mysql主从库不同步1236错误:could not find first log file name in binary....

问题分析:

  1. 主库执行命令,确认日志文件和位置;

mysql > show master status;

+------------------+----------+--------------+------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB             | Executed_Gtid_Set |
+------------------+----------+--------------+------------------------------+-------------------+
| mysql-bin.001724 | 703460812|              | information_schema,sys,mysql |                   |
+------------------+----------+--------------+------------------------------+-------------------+
  1. 从库执行命令,确认日志文件和位置;

mysql > show master status;

+------------------+----------+--------------+------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB             | Executed_Gtid_Set |
+------------------+----------+--------------+------------------------------+-------------------+
| mysql-bin.001240 | 333460812|      ***     | information_schema,sys,mysql |                   |
+------------------+----------+--------------+------------------------------+-------------------+

解决办法:

  1. 首先停止从库同步;

mysql > stop slave ;

  1. 主库中关闭当前的二进制日志文件并创建一个新文件,新的二进制日志文件的名字在当前的二进制文件的编号上加1。

mysql > flush logs;

  1. 查看主库状态,主要查看日志文件和位置:

mysql > show master status;

  1. 回到从库中,执行命令,使日志文件和位置对应主库:

mysql > CHANGE MASTER TO MASTER_LOG_FILE='log-bin.000005',MASTER_LOG_POS=107;

  1. 最后,启动从库:

mysql > start slave ;

mysql > show slave status;
设置忽略错误命令:set global sql_slave_skip_counter =1;

状态如下,基本上是正常了,可以主库修改,测试一下从库是否同步。

Slave_IO_State: Waiting for master to send event
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

如出现异常:ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository

mysql > reset slave;
mysql > start slave;

相关文章

网友评论

    本文标题:Mysql主从库不同步1236错误:could not find

    本文链接:https://www.haomeiwen.com/subject/zleoirtx.html