MySQL主从不同步解决

1、由于binlog日志带多删除了几个后发现MySQL主从不同步
 
mysql> show slave status\G;
 
              Slave_IO_Running: No
            Slave_SQL_Running: Yes
 
查看报错日志为
 
 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file',
 
解决方式
 
从服务器配置:
 

主服务器查看
 
mysql> show master status;
 
+------------------+----------+--------------+------------------+
 
| File            | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 
+------------------+----------+--------------+------------------+
 
| mysql-bin.000005 |      106 |              |                  |
 
+------------------+----------+--------------+------------------+
 
1 row in set (0.00 sec)
 
从服务器设置
 
mysql> change master to master_host='192.168.0.10',master_user='replication',master_password='replication',master_log_file='mysql-bin.000003',master_log_pos=106;
 
Query OK, 0 rows affected (0.03 sec)
 
 
 
mysql>stop slave;
 
mysql>start slave;
 
 
 
主服务器配置
 
从服务器上查看
 
mysql> show master status;
 
+------------------+----------+--------------+------------------+
 
| File            | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 
+------------------+----------+--------------+------------------+
 
| mysql-bin.000005 |      106 |              |                  |
 
+------------------+----------+--------------+------------------+
 
1 row in set (0.00 sec)
 
主服务器配置
 
mysql> change master to master_host='192.168.0.11',master_user='replication',master_password='replication',master_log_file='mysql-bin.000005',master_log_pos=106;
 
Query OK, 0 rows affected (0.03 sec)
 
mysql>stop slave;
 
mysql>start slave;
 
在查看slave状态ok解决。

相关推荐