error 1236 from master when reading data from binary log: 'Slave can not handle replication events w

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: <p><span style="color:rgb(51,102,255)">error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log</span> 

error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log    

         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: mysql.%,test.%
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 451
              Relay_Log_Space: 302
              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: 'Slave can not handle replication events with the checksum that master is configured to log; the first event 'mysql-bin.000001' at 451, the last event read from './mysql-bin.000001' at 451, the last byte read from './mysql-bin.000001' at 120.'
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 

             Master_Server_Id: 1


show slave status \G;

环境:

centos 6.5 

主---主--从--从--从(本环境)

也适用:

主-----从----从----从

主库: 5.6.25 

从库:5.5.32


解决:

主库添加:

vim /etc/my.cnf

binlog_checksum=none

主库 重新  show master status \G

记录下来 

mysql-bin.000002 |      439 

从库 

change master to master_host='192.168.199.40',master_port=3306,master_user='slave',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=439;

启动从库

start slave 

show slave status \G


Slave_IO_Running: Yes (主库推送binlog线程) 必须yes,不然没法交互,他们要通信的。
Slave_SQL_Running: Yes(从库重放线程)必须yes,不然没法复制



问题解决。

原因:

主库用的 mysql5.6 , binlog_checksum 默认设置的是 crc32。新手建议,多看my.cnf,务必精通。就像开发的API那样。你懂的!


赠送:

    网站有一个后台业务,叫searchEngine项目,基于Lucene 构建。主要提供索引构建和检索的功能,搜索引擎查询mysql 数据库然后根据数据状态来构建索引,这里采用的是 程序每隔一段时间主动轮询 mysql 查询 数据列 增删改的状态,对应的去增删改 Lucene 索引,然后会将索引的状态更新到数据列中,方便轮询的时候区分哪些是未索引的数据。

    由于mysql主要采用myisam引擎,导致java程序构建索引 轮询数据库的时候,频繁锁表,页面查询的时候无法响应。这里做了下 mysql 主从同步,将所有业务上的更新和查找在 master 上进行,而Lucene后台服务操作slave库,同时也起到备份的作用。这里整理下做主从备份的一些配置。

    主库 master:192.168.0.102,mysql 5.6.12,centos

    从库 slave:192.168.0.100,mysql 5.5.13,centos

都是采用源码编译,安装过程可以查看我的这篇博文。master、slave 所有的数据表结构都一致。之前我做了一个双master 的配置,可以查看这里

1. master 配置

这里的配置只截取了部分 同步需要的配置,其他的优化方面的暂不考虑

my.cnf:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[client]
port=3306
[mysqld]
socket= /usr/local/mysql/mysql .sock
basedir= /usr/local/mysql
datadir= /usr/local/mysql/data
log-error= /usr/local/mysql/data/mysql_error .log
pid- file = /usr/local/mysql/data/mysql .pid
log-bin = /usr/local/mysql/mysql-bin .log #二进制文件必须开启
explicit_defaults_for_timestamp= true
innodb_flush_log_at_trx_commit=2 #日志flush到磁盘的,2表示写入到缓存,提高性能,操作系统崩溃会丢失部分数据
#master
server_id=1
expire_logs_days = 10
max_binlog_size = 1G
binlog- do -db = webportal #同步数据库
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=mysql
binlog-ignore-db= test

    创建同步用户,在主服务器上为从服务器建立一个连接帐户,该帐户必须授予REPLICAITON SLAVE权限。在主服务器登陆mysql上执行

?
1
grant replication slave on *.* to 'replication' @ '192.168.0.100' identified by '123456' ;

注: replication@192.168.0.100这里是客户端的ip 可以使用 % 代替,表示允许任意的客户端,例如:

192.168.0.% 。表示该段地址的主机都可作为客户端。

查看master 状态:

?
1
2
3
4
5
6
7
8
mysql> show master status\G;
*************************** 1. row ***************************
              File: mysql-bin.000001
          Position: 416
      Binlog_Do_DB: webportal
  Binlog_Ignore_DB: information_schema,performance_schema,mysql, test
Executed_Gtid_Set:
1 row in set (0.00 sec)
注意上面的 File 和 Position :slave 配置的时候会使用。

2. slave配置

?
1
2
3
4
[mysqld]
server_id=2
log-bin=mysql-bin.log
replicate- do -db=webportal
用change master语句指定同步位置
?
1
2
3
mysql>change master to master_host= '192.168.0.102' , master_user= 'replication' , master_password= '123456' , master_log_file= 'mysql-bin.000001' , master_log_pos=525;
 
注:master_log_file,master_log_pos由上面master查出的状态值中确定。master_log_file对应File,master_log_pos对应Position。
启用slave;
?
1
start slave;

关闭slave;

?
1
stop slave;

查看状态:

?
1
show slave status;

这里出现了这样一个错误:

Last_IO_Error: Got fatal error 1236 from master when reading data from >> binary log: 'Slave can not handle replication events with the checksum that >> master is configured to log; the first event 'mysql-bin.000001'
这是由于 master 用的 mysql5.6 , binlog_checksum 默认设置的是 crc32。 如果slave用的 5.5 或者更早的版本,请将master的 binglog_checksum设置为 none。
binlog_checksum=none

重启master : ./mysqld restart 

查看slave :show slave status\G;

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mysql> show slave status\G;
*************************** 1. row ***********
                Slave_IO_State: Waiting for mas
                   Master_Host: 192.168.0.102
                   Master_User: replication
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.00000
           Read_Master_Log_Pos: 120
                Relay_Log_File: YZ-relay-bin.00
                 Relay_Log_Pos: 266
         Relay_Master_Log_File: mysql-bin.00000
              Slave_IO_Running: Yes  #必须为yes
             Slave_SQL_Running: Yes  #必须为yes
               Replicate_Do_DB: webportal
           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: 120
               Relay_Log_Space: 419
               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: 0
                 Last_IO_Error:
                Last_SQL_Errno: 0
                Last_SQL_Error:
   Replicate_Ignore_Server_Ids:
              Master_Server_Id: 1
1 row in set (0.00 sec)

注:Slave_IO及Slave_SQL进程必须正常运行,即YES状态,否则都是错误的状态(如:其中一个NO均属错误)。


参考:

http://my.oschina.net/congqian/blog/138485


赠送2


MySQL 搭建主从同步,从报 Slave can not handle replication events with the checksum that master 错误问题

心血来朝,想复习一下MySQL主从搭建,虽开打VM,分别开启了我以前安装的两台虚拟机,一台CentOS6 一台Ubuntu,这两台都安装好了MySQL数据库,安装啥的不说了,配置也没问题。但是但我把主上的数据库dump出来,复制来从上,然后做同步的时候报错了:

1
2
3
4
Slave_IO_Running: No
Slave_SQL_Running: Yes
 
     Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log; the first event ' binlog.000005 ' at 805, the last event read from ' /data/dbdata/mysqllog/binlog/binlog .000005 ' at 805, the last byte read from ' /data/dbdata/mysqllog/binlog/binlog .000005 ' at 120.'

百思不得奇解,还叫过DBA把我从做了一遍,还是报这个错,虽放 Google 一搜索,好家伙。

这是由于 master 用的 mysql5.6 , binlog_checksum 默认设置的是 crc32。 如果slave用的 5.5 或者更早的版本,请将master的 binglog_checksum设置为 none。

才记起来我 CentOS6 安装的是 mysql 5.6 版本, Ubuntu系统上安装的是 5.5版本

1
2
3
4
5
6
7
root@mysql 19:22> select @@version;
+------------+
| @@version  |
+------------+
| 5.6.16-log |
+------------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
root@(none) 19:36> select @@version;
+------------+
| @@version  |
+------------+
| 5.5.27-log |
+------------+
1 row in set (0.00 sec)

解决步骤:

  1. 关闭 master checksum:
1
2
3
set global binlog_checksum= 'NONE' ;
 
show variables like '%checksum%' ;
  1. 添加 my.cnf 配置文件中添加如下设置,下次重启就可以不用做步骤1,直接生效了。
1
binlog_checksum=NONE
  1. 重新查询master状态:
1
show master status\G;

搞定。
然后我叫DAB也要把这问题好好记一下,没准下次就会遇到了。

binlog checksum功能介绍

http://blog.sina.com.cn/s/blog_53fab15a0102vodv.html

参考:

https://www.liurongxing.com/mysql-slave-can-not-handle-replication-events-with-the-checksum-that-master.html


后来发现是因为主库MySQL版本是5.6, 从库是5.5

5.6的版本中加入了replication event checksum,主从复制时间校验功能,所以需要把这个关掉才能正常同步到5.5的slave

修改主库 /etc/my.cnf

增加下一行

binlog_checksum=none

重启mysql

现在再看从库status就正常了~












相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
2月前
|
SQL 关系型数据库 MySQL
MySQL数据库,可以使用二进制日志(binary log)进行时间点恢复
对于MySQL数据库,可以使用二进制日志(binary log)进行时间点恢复。二进制日志是MySQL中记录所有数据库更改操作的日志文件。要进行时间点恢复,您需要执行以下步骤: 1. 确保MySQL配置文件中启用了二进制日志功能。在配置文件(通常是my.cnf或my.ini)中找到以下行,并确保没有被注释掉: Copy code log_bin = /path/to/binary/log/file 2. 在需要进行恢复的时间点之前创建一个数据库备份。这将作为恢复的基准。 3. 找到您要恢复到的时间点的二进制日志文件和位置。可以通过执行以下命令来查看当前的二进制日志文件和位
106 1
|
16天前
|
Android开发
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
21 1
|
2月前
|
SQL JSON Kubernetes
Seata常见问题之服务端 error日志没有输出,客户端执行sql报错如何解决
Seata 是一个开源的分布式事务解决方案,旨在提供高效且简单的事务协调机制,以解决微服务架构下跨服务调用(分布式场景)的一致性问题。以下是Seata常见问题的一个合集
119 0
|
7月前
|
Java 程序员
【日志级别】log4j的8个日志级别(OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL)
【日志级别】log4j的8个日志级别(OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL)
352 0
|
7月前
批量打印 SAP CRM 系统所有包含 Error Message Log 的 订单
批量打印 SAP CRM 系统所有包含 Error Message Log 的 订单
34 0
|
8月前
|
应用服务中间件 PHP nginx
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
56 1
|
9月前
|
Java
成功解决:ERROR StatusLogger No log4j2 configuration file found.
成功解决:ERROR StatusLogger No log4j2 configuration file found.
|
11月前
|
存储 设计模式 缓存
详解MySQL Error Log
Error Log是MySQL的一个非常重要的日志,主要用来记录mysqld的启动和关闭,以及mysqld启动,关闭以及运行期间的诊断信息。本文主要对Error Log的初始化以及写入过程做一个详细的介绍。以下介绍基于MySQL 8.0.28。初始化日志服务的初始化代码调用堆栈如下:- mysqld_main   - init_error_log   //初始化日志子系统   - log_buil
详解MySQL Error Log
|
12月前