数据库

解决MySQL主从复制错误1595:Relay log write failure…

Jager · 3月16日 · 2019年 · · 950次已读

先交代下背景:我这边正在研究基于Docker的MariaDB Galera Cluster的自动化集群部署方案【以下简称MGC,后续有时间可以考虑分享下这个方案】,已经完成所有调试,想在生产环境部署一个MGC集群作为从先灰度测试。解决MySQL主从复制错误1595:Relay log write failure...

生产环境主DB版本为MySQL5.5,新的MGC采用Mariadb最新10.3.12 stable版本,做好MGC集群,并导入一份从主DBdump出来的完整SQL之后,change master 开始创建主从,结果如下报错:

MariaDB [(none)]> show slave status\G                                                                                                                                                      
*************************** 1. row ***************************
                Slave_IO_State: 
                   Master_Host: x.x.x.x
                   Master_User: rpl
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.001411
           Read_Master_Log_Pos: 360808406
                Relay_Log_File: mysql-relay-bin.000001
                 Relay_Log_Pos: 4
         Relay_Master_Log_File: mysql-bin.001411
              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: 360808406
               Relay_Log_Space: 256
               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: 1595
                 Last_IO_Error: Relay log write failure: could not queue event from master
                Last_SQL_Errno: 0
                Last_SQL_Error: 
   Replicate_Ignore_Server_Ids: 
              Master_Server_Id: 15410
                Master_SSL_Crl: 
            Master_SSL_Crlpath: 
                    Using_Gtid: No
                   Gtid_IO_Pos: 
       Replicate_Do_Domain_Ids: 
   Replicate_Ignore_Domain_Ids: 
                 Parallel_Mode: conservative
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
              Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 0
1 row in set (0.00 sec)

查了下资料,都是是磁盘满导致的,但是我这边磁盘空间、权限都没问题,于是继续检查了下MGC节点日志如下:

2019-01-28 10:47:26 11 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.001411' at position 512281317, relay log './mysql-relay-bin.000003' position: 151473377
2019-01-28 10:47:26 10 [Note] Slave I/O thread: connected to master '[email protected]:3306',replication started in log 'mysql-bin.001413' at position 412624945
2019-01-28 10:47:26 10 [Warning] Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error: Unknown system variable 'binlog_checksum', Internal MariaDB error code: 1193
2019-01-28 10:47:26 10 [ERROR] Slave I/O: Replication event checksum verification failed while reading from network, Internal MariaDB error code: 1743
2019-01-28 10:47:26 10 [ERROR] Slave I/O: Relay log write failure: could not queue event from master, Internal MariaDB error code: 1595
2019-01-28 10:47:26 10 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.001413', position 412624945

里面有一个关键信息:binlog_checksum failed,看来报错和这个有关系了。查了下资料,应该是Mariadb默认打开了 slave_sql_verify_checksum(MySQL版本默认关闭),而主从版本又不一致,导致checksum失败。

解决办法也很简单,在MGC各节点的[msyqld]配置中加上:slave_sql_verify_checksum=0 ,关闭这个特性即可,具体有没有负面影响暂未深入研究。

10 条回应
  1. 老部落运维 2019-3-18 · 14:41

    想与贵站交换首页链接,不知可否?
    我站:https://www.laobuluo.com/
    站名:老部落运维

  2. 春色集 2019-3-18 · 17:31

    学习了感谢博主

  3. hack520.com 2019-3-18 · 23:59

    最新也在学习 Docker,这东西功能很强大!

  4. 锋言锋语 2019-3-20 · 15:58

    大神的博客文章我都看不懂,悲哀!

  5. 小龙 2019-5-7 · 14:15

    zhangge请教这个评论插件叫啥?还有你越来越懒了~文章好敷衍啊。hh

    • Jager 2019-5-17 · 9:26

      1、没插件,自己折腾代码。
      2、写的详细就说啰嗦,写得简洁就说敷衍,你让我情何以堪?

  6. 吴先森 2019-6-15 · 23:38

    写的不错,不过想问个问题,,,为什么评论的昵称等等数据不能自动保存啊,,每次想评论都要重新填一次,有点小麻烦,,还有,表情很老旧了,建议一换

    • Jager 2019-6-16 · 23:20

      怕是你的浏览器开了无痕模式,我测试是没啥问题;表情有空再说

      • 吴先森 2019-6-22 · 16:43

        发现真的是在无痕标签下打开的,尴尬,

        • 吴先森 2019-6-22 · 16:45

          呸,浏览器一直在无痕模式下,,,,以前用过一次结果忘关了,