【问题标题】:Mysql error 1236 from master when reading data from binary log从二进制日志中读取数据时,来自master的Mysql错误1236
【发布时间】:2015-03-03 17:23:23
【问题描述】:

我有 2 个具有主/从配置的 MySql,并且复制失败。 MySql Master 崩溃并在 mysql-bin.index 中创建了一个新寄存器。我删除了这个新寄存器,因为文件系统中不存在这个文件。然后MySql Master重启成功。

现在,我在从站中出现了下一个错误:

mysql> show slave status \G
*************************** 1. row ***************************
           Slave_IO_State: 
              Master_Host: 10.64.253.99
              Master_User: replication
              Master_Port: 3306
            Connect_Retry: 60
          Master_Log_File: mysql-bin.001050
      Read_Master_Log_Pos: 54868051
           Relay_Log_File: mysqld-relay-bin.000001
            Relay_Log_Pos: 4
    Relay_Master_Log_File: mysql-bin.001050
         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: 54868051
          Relay_Log_Space: 107
          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: NULL
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: 'Could not find first log file name in binary log index file'
           Last_SQL_Errno: 0
           Last_SQL_Error: 
Replicate_Ignore_Server_Ids: 
         Master_Server_Id: 1

如果我执行“show master status”查看mysql bin日志文件和位置:

mysql> show master status \G
*************************** 1. row ***************************
            File: mysql-bin.001050
        Position: 55586895
    Binlog_Do_DB: aaa
 Binlog_Ignore_DB: xxx,yyy,zzz,mysql

然后我为从站设置新配置:

STOP SLAVE;
CHANGE MASTER TO 
    MASTER_HOST='10.64.253.99',
    MASTER_USER='slaveUser',
    MASTER_PASSWORD='12345',
    MASTER_LOG_FILE='mysql-bin.001050', 
    MASTER_LOG_POS=55586895;
START SLAVE;

如果我再次检查从站状态,我会遇到同样的错误:

mysql> show slave status \G
*************************** 1. row ***************************
           Slave_IO_State: 
              Master_Host: 10.64.253.99
              Master_User: replication
              Master_Port: 3306
            Connect_Retry: 60
          Master_Log_File: mysql-bin.001050
      Read_Master_Log_Pos: 55586895
           Relay_Log_File: mysqld-relay-bin.000001
            Relay_Log_Pos: 4
    Relay_Master_Log_File: mysql-bin.001050
         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: 55586895
          Relay_Log_Space: 107
          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: NULL
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: 'Could not find first log file name in binary log index file'
           Last_SQL_Errno: 0
           Last_SQL_Error: 
 Replicate_Ignore_Server_Ids: 
         Master_Server_Id: 1

我已经在MySql Master中检查了mysql-bin.001050存在并且不为空。

这是一个生产环境,每分钟都会插入新数据。位置值可以以分钟或秒为单位进行更改。不知道是不是这个问题。

两个MySql中max_allowed_pa​​cket变量的值相同(16M)。

为什么slave找不到二进制日志文件?

【问题讨论】:

    标签: mysql replication master-slave


    【解决方案1】:

    你可以试试这个:

    1. 从机:stop slave;
    2. 主人:flush logs
    3. 主人:show master status; — take note of the master log file and master log position

    4. 从机:CHANGE MASTER TO MASTER_LOG_FILE='log-bin.00000X', MASTER_LOG_POS=106;

    5. 从机:start slave

    【讨论】:

    • 这是不安全的方式,你需要清楚地了解你在做什么。
    • @AlexeyVMP 你能提供最安全的方法来处理这个吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 2020-03-17
    • 1970-01-01
    相关资源
    最近更新 更多