首页 » Linux » Got fatal error 1236 错误及 解决方法

Got fatal error 1236 错误及 解决方法

 

从库出现以下错误:

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State:

Master_Host: 192.168.168.245

Master_User: rep1

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000136 #binlog的文件

Read_Master_Log_Pos: 2849 #binlog的同步到上文件的位置,

Relay_Log_File: relay-bin.000154

Relay_Log_Pos: 4

Relay_Master_Log_File: mysql-bin.000136

Slave_IO_Running: No

Slave_SQL_Running: Yes

Last_IO_Errno: 1236

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Binlog has bad magic number;  It’s not a binary log file that can be used by this version of MySQL’

 

 

解决方法:

原因是主库中mysql-bin.000136的文件有问题,可以考虑跳到该文件的下一个位置。

1、然后去主库查看这个文件信息如下:

[root@mysql_server mysql]# mysqlbinlog mysql-bin.000136

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;

/*!40019 SET @@session.max_insert_delayed_threads=0*/;

/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;

DELIMITER /*!*/;

ERROR: File is not a binary log file.

DELIMITER ;

# End of log file

ROLLBACK /* added by mysqlbinlog */;

/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

 

2、发现以上文件本身里有有错误,也没有位置,所以只好在从库上跳到下一个binlog文件的第一个位置(以end_log_pos开头的是)。

[root@mysql_server mysql]# mysqlbinlog mysql-bin.000137|head -30

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;

/*!40019 SET @@session.max_insert_delayed_threads=0*/;

/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;

DELIMITER /*!*/;

# at 4

#160120  0:00:01 server id 1  end_log_pos 107   Start: binlog v 4, server v 5.5.32-log created 160120  0:00:01

BINLOG ‘

gV2eVg8BAAAAZwAAAGsAAAAAAAQANS41LjMyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==

‘/*!*/;

# at 107

#160120 15:20:37 server id 1  end_log_pos 180   Query   thread_id=95    exec_time=0     error_code=0

SET TIMESTAMP=1453274437/*!*/;

SET @@session.pseudo_thread_id=95/*!*/;

SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

SET @@session.sql_mode=0/*!*/;

SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;

/*!\C utf8 *//*!*/;

SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;

SET @@session.lc_time_names=0/*!*/;

SET @@session.collation_database=DEFAULT/*!*/;

BEGIN

/*!*/;

# at 180

#160120 15:20:37 server id 1  end_log_pos 371   Query   thread_id=95    exec_time=0     error_code=0

use `wordpress`/*!*/;

SET TIMESTAMP=1453274437/*!*/;

UPDATE `clc_options` SET `option_value` = ‘1453274437.4652280807495117187500’ WHERE `option_name` = ‘_transient_doing_cron’

/*!*/;

# at 371

 

3、然后在从库切换到上面的位置:

stop slave;change master to master_log_file=’mysql-bin.000137′,master_log_pos=107;

start slave;

show slave status\G

发现正常了。

mysql> stop slave;

Query OK, 0 rows affected (0.06 sec)

 

mysql> change master to master_log_file=’mysql-bin.000137′,master_log_pos=107;

Query OK, 0 rows affected (0.14 sec)

 

mysql> start slave;

Query OK, 0 rows affected (0.04 sec)

原文链接:Got fatal error 1236 错误及 解决方法,转载请注明来源!

0