《MySQL系列-主从相关》MySQL从库Slave_IO_Running异常,Last_IO_Error: Got fatal error 1236 from master when reading

Posted DATA数据猿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《MySQL系列-主从相关》MySQL从库Slave_IO_Running异常,Last_IO_Error: Got fatal error 1236 from master when reading相关的知识,希望对你有一定的参考价值。

mysql从库Slave_IO_Running异常,Last_IO_Error: Got fatal error 1236 from master when reading data from binary log

一、从库Slave_IO_Running异常

从库start slave;启动后,通过show slave status\\G;查看主从状态,结果Relay_Master_Log_File异常,Last_IO_Error: Got fatal error 1236 from master when reading data from binary log:

                  Master_User: slave
                  Master_Port: 33061
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000004
          Read_Master_Log_Pos: 1140
               Relay_Log_File: relay-log-master_1.000002
                Relay_Log_Pos: 320
        Relay_Master_Log_File: mysql-bin.000004
             Slave_IO_Running: No
            Slave_SQL_Running: Yes

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'A slave with the same server_uuid/server_id as this slave has connected to the master; the first event 'mysql-bin.000004' at 1140, the last event read from './mysql-bin.000004' at 123, the last byte read fro

二、主库刷新日志

刷新日志后binlog文件的位置会+1

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.000005 |      154 | zxy          |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

四、主库重置salve

# 1.先关闭slave
mysql> stop slave;
Query OK, 0 rows affected (0.01 sec)

# 2.重置slave
mysql> reset slave;
Query OK, 0 rows affected (0.08 sec)

五、重新配置连接master

重新连接时,只需要修改MASTER_LOG_FILE、MASTER_LOG_POS即可

mysql> CHANGE MASTER TO MASTER_HOST='121.4.106.102' ,MASTER_PORT=33061,MASTER_USER='slave',MASTER_PASSWORD='slave',MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=154 for channel 'master_1';
Query OK, 0 rows affected, 2 warnings (0.05 sec)

六、重启slave

# 1.启动slave
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
# 2.查看状态,启动成功
mysql> show slave status\\G;
Query OK, 0 rows affected (0.01 sec)

				  Master_User: slave
                  Master_Port: 33061
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 154
               Relay_Log_File: relay-log-master_1.000002
                Relay_Log_Pos: 320
        Relay_Master_Log_File: mysql-bin.000005
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

以上是关于《MySQL系列-主从相关》MySQL从库Slave_IO_Running异常,Last_IO_Error: Got fatal error 1236 from master when reading的主要内容,如果未能解决你的问题,请参考以下文章

mysql主从配置,innobackup备份

高性能MySql系列-读写分离/主从复制/主从复制延时解决方案

(5.9)mysql高可用系列——正常主从切换测试

MySQL主从复制与GTID主从复制

Mysql面试题

MySQL主从复制