Mysql主从复制,IO线程显示NO

last_IO_Error:当从二进制日志中读取数据时,从主服务器得到致命错误1236:“使用主服务器的SERVER_UUID,从服务器拥有比主服务器更多的GT ID。”这可能表明二进制日志的结尾被截断了,或者最后一个二进制日志文件丢失了,例如,当sync_binlog!=1时,电源或磁盘出现故障。主服务器可能回滚了已经复制到从服务器的事务,也可能没有回滚。建议复制主服务器从从属服务器回滚到主服务器的任何事务,和/或将主服务器上的空事务提交到Account以处理已被



mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.198.199
                  Master_User: qaq
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: localhost-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 0
              Relay_Log_Space: 154
              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: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Slave has more GTIDs than the master has, using the master's SERVER_UUID. This may indicate that the end of the binary log was truncated or that the last binary log file was lost, e.g., after a power or disk failure when sync_binlog != 1. The master may or may not have rolled back transactions that were already replicated to the slave. Suggest to replicate any transactions that master has rolled back from slave to master, and/or commit empty transactions on master to account for transactions that have been'
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
         

【以下回答由 GPT 生成】

根据上述问题描述,该问题可能是由于主服务器的二进制日志的结尾被截断或丢失导致的。以下是解决此问题的步骤:

步骤 1: 检查主服务器的二进制日志

首先,我们需要检查主服务器的二进制日志是否完整。执行以下命令查看主服务器的二进制日志文件和位置:

SHOW MASTER STATUS;

请提供此命令的输出结果。

步骤 2: 检查从服务器的二进制日志

执行以下命令查看从服务器的二进制日志文件和位置:

SHOW SLAVE STATUS\G;

请提供此命令的输出结果。

步骤 3: 恢复丢失的二进制日志

如果从服务器的二进制日志文件和位置比主服务器的要领先,说明从服务器的二进制日志已经超出了主服务器的范围。在这种情况下,我们需要恢复丢失的二进制日志。

首先,通过以下命令获取主服务器缺失的二进制日志文件名和位置:

SHOW BINLOG EVENTS IN 'master-binlog-filename' FROM `master-binlog-position`\G;

确保将 'master-binlog-filename' 和 'master-binlog-position' 替换为主服务器缺失二进制日志的文件名和位置。

然后,找到从服务器缺失的二进制日志文件并将其复制到从服务器的二进制日志目录中。

最后,通过以下命令告诉从服务器从新复制的二进制日志文件位置开始读取:

CHANGE MASTER TO MASTER_LOG_FILE='new-master-binlog-filename', MASTER_LOG_POS=new-master-binlog-position;

确保将 'new-master-binlog-filename' 和 'new-master-binlog-position' 替换为新复制的二进制日志文件名和位置。

步骤 4: 重新启动主从复制

最后,重新启动从服务器的主从复制进程,使其开始从主服务器同步数据:

START SLAVE;

通过执行以下命令确认从服务器的主从复制状态是否已经修复:

SHOW SLAVE STATUS\G;

确保将此命令的输出结果与之前提供的输出结果进行比较。

如果问题仍然存在,或者没有提供必要的输出结果来进行进一步分析,请重新提供相关的输出结果。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^