Mysql 主从复制 由于binlog位置不同导致从节点无法复制

报错:Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'。

 

解决办法 :

 

1.先到从库停止服务:

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

 

2.查看主库binlog文件和数据节点:

mysql> show master status;
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+
| mysql-bin.000015 | 5197 | sycdemo,sycdemo01 | information_schema,performation_schema,mysql,sys,sycdemo02 | |
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+
1 row in set (0.00 sec)

 

3.刷新日志并查看新的日志信息:

mysql> flush logs;
Query OK, 0 rows affected (0.01 sec)

 

mysql> show master status;
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+
| mysql-bin.000016 | 156 | sycdemo,sycdemo01 | information_schema,performation_schema,mysql,sys,sycdemo02 | |
+------------------+----------+-------------------+------------------------------------------------------------+-------------------+

 

 

4.重新设置从库上主库的binlog信息:

mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000016',MASTER_LOG_POS=156;
Query OK, 0 rows affected, 3 warnings (0.01 sec)

 

 

5.查看从库上配置信息:

mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.119.130
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000016
Read_Master_Log_Pos: 156

 

配置成功,更新数据查看。

 

posted @ 2022-11-11 18:33  爵士灬  阅读(854)  评论(0编辑  收藏  举报