故障说明
晚上备用服务器自动重启,收到报警,备用服务器上的mariadb从库无法去同步主库。启动mariadb后,报如下错误(重点看红色字体) 
mariadb_1              | -- ::  [Note] Plugin 'FEEDBACK' is disabled.
mariadb_1 | -- :: [Note] Recovering after a crash using mysql-bin
mariadb_1 | -- :: [Note] Starting crash recovery...
mariadb_1 | -- :: [Note] Crash recovery finished.
mariadb_1 | -- :: [Note] Server socket created on IP: '0.0.0.0'.
mariadb_1 | -- :: [Warning] 'proxies_priv' entry '@% xxx@xxx' ignored in --skip-name-resolve mode.
mariadb_1 | -- :: [Note] Reading of all Master_info entries succeded
mariadb_1 | -- :: [Note] Added new Master_info '' to hash table
mariadb_1 | -- :: [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--log-basename=#' or '--relay-log=mysqld-relay-bin' to avoid this problem.
mariadb_1 | -- :: [Note] mysqld: ready for connections.
mariadb_1 | Version: '10.2.14-MariaDB-10.2.14+maria~jessie-log' socket: '/var/run/mysqld/mysqld.sock' port: mariadb.org binary distribution
mariadb_1 | 2018-09-15 17:04:28 140261962921728 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000239' at position 13999540, relay log './mysqld-relay-bin.000261' position: 13999839
mariadb_1 | 2018-09-15 17:04:28 140261962921728 [ERROR] Error in Log_event::read_log_event(): 'Event truncated', data_len: 489, event_type: 2
mariadb_1 | -- :: [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
mariadb_1 | -- :: [ERROR] Slave SQL: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave. Internal MariaDB error code:
mariadb_1 | -- :: [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000239' position
mariadb_1 | -- :: [Note] Slave SQL thread exiting, replication stopped in log 'mysql-bin.000239' at position
mariadb_1 | -- :: [Note] Slave I/O thread: connected to master 'xxx@xxx.xxx.xxx.xxx:3306',replication started in log 'mysql-bin.000239' at position
mariadb_1 | -- :: [Note] InnoDB: Buffer pool(s) load completed at ::

原因分析

 
mariadb_1              | -- ::  [ERROR] Error in Log_event::read_log_event(): 'Event truncated', data_len: , event_type: 
这个错误表示relay-log存在错误,导致从库想把mysqld-relay-bin.000261的13999839恢复到mysql-bin.000239的13999540失败。relay-log出错,可能是从库relay-log自身出错,也可能是主库的binlog有问题。本次从机自动重启,而其他从机仍然与主服务器在正常同步,于是判定为从库relay-log自身出错。
如果relay-log(binlog)文件有错误,通过mysqlbinlog <relay log路径> > /dev/null测试,也会打出上面一样的错误。
 

解决方法
一、从机清除掉出错位置之后的relay-log,在SQL客户端执行:
> STOP SLAVE;
> RESET SLAVE;
二、从出错位置重新同步,本次出错位置为:'mysql-bin.000239' position 13999540 
 

mariadb(mysql)从库relaylog损坏无法同步的处理方法的更多相关文章

  1. MySQL主主互备不同步的解决方法

    MySQL主主互备不同步 首先在服务器上执行show slave satus;可以看到很多同步的参数: Master_Log_File: SLAVE中的I/O线程当前正在读取的主服务器二进制日志文件的 ...

  2. 创建MySQL从库

    我们知道Oracle有DataGuard实时备份数据.能够做主备切换,而MySQL也有自己的一套备库方案.称之为主从复制. 搭建MySQL从库是为了实时同步主库数据,同一时候也能够分担主库的读压力.对 ...

  3. MYSQL主从库同步配置过程

    MYSQL主从库同步配置过程 为了实现网站数据库的异地备份,采用了MySQL数据库主从同步配置,需要两台服务器分别作为主从库,当主库发生增删改等操作,会实时反映到从库,我的个人服务器配置如下: 主库为 ...

  4. Mariadb/Mysql命令行常用命令

    一.初始化等 1.登陆数据库方法    mysql -u 用户名 -p 用户密码 2.修改root及用户密码 use mysql; update user set password=password( ...

  5. Mariadb/Mysql 主从复制(1)

    一.原理 mysql的主从数据同步是一个异步复制过程,需要master开启bin-log日志功能,bin-log记录了master库中的增.删.修改.更新操作的sql语句,整个过程需要开启3个线程,分 ...

  6. MySQL数据的主从复制、半同步复制和主主复制详解

    一.MySQL复制概述 ⑴.MySQL数据的复制的基本介绍 目前MySQL数据库已经占去数据库市场上很大的份额,其一是由于MySQL数据的开源性和高性能,当然还有重要的一条就是免费~不过不知道还能免费 ...

  7. MySQL数据的主从复制、半同步复制和主主复制详解-转

    一.MySQL复制概述 ⑴.MySQL数据的复制的基本介绍 目前MySQL数据库已经占去数据库市场上很大的份额,其一是由于MySQL数据的开源性和高性能,当然还有重要的一条就是免费~不过不知道还能免费 ...

  8. Asp.Net Core 轻松学-使用MariaDB/MySql/PostgreSQL和支持多个上下文对象

    前言 在上一篇文章中(Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库)[https://www.cnblogs.com/viter/p/10243577.html],介 ...

  9. 【MySQL】MySQL主从库配置和主库宕机解决方案

    1.转载:https://blog.csdn.net/zfl589778/article/details/51441719/ 2.效果:亲测有效,数据写入成功. 3.主机宕机后,如果不是长时间宕机,且 ...

随机推荐

  1. net 串口通讯 网口通讯(Socket)

    1.串口通讯 2.网口(Socket) 源码下载:源码附件

  2. .NET 任务调度Quartz系列(1)——自建定时任务

    在我们平时项目中经常会遇到定时任务,比如定时同步数据,定时备份数据,定时统计数据等,定时任务我们都知道使用Quartz.net,此系列写的也是Quartz,但是在此之前,我们先用其他方式做个简单的定时 ...

  3. .Net core 应用程序发布Web时,有些文件夹没有发布成功解决办法

    如果文件是你在项目中手动添加的, 那么在解决方案中右击文件,然后点击属性,文件属性----高级----复制到输出目录----改为始终复制/如果较新则复制 即可.

  4. 统一登录中心SSO 单点登录系统的构想

    什么是单点登录?我想肯定有一部分人“望文生义”的认为单点登录就是一个用户只能在一处登录,其实这是错误的理解.单点登录指的是多个子系统只需要登录一个,其他系统不需要登录了(一个浏览器内).一个子系统退出 ...

  5. 基于MVC框架Aspose.Words打印到Word中写法

    控件bin文件下载地址:https://download.csdn.net/download/u012949335/10610726 //前端打印写法 @{ ViewBag.Title = " ...

  6. CC2530学习路线-基础实验-GPIO 控制LED灯亮灭(1)

    目录 1.前期预备知识 1.1 新大陆ZigBee模块LED灯电路 1.2 CC2530相关寄存器 1.3 寄存器操作技巧 1.4 CPU空转延时 1.4 操作流程图 2.程序代码 The End 1 ...

  7. 栈的实现——c++

    栈(stack),是一种线性存储结构,它有以下几个特点: (01) 栈中数据是按照"后进先出(LIFO, Last In First Out)"方式进出栈的. (02) 向栈中添加 ...

  8. 【zookeeper】Apache curator的使用及zk分布式锁实现

    上篇,本篇主要讲Apache开源的curator的使用,有了curator,利用Java对zookeeper的操作变得极度便捷. 其实在学之前我也有个疑虑,我为啥要学curator,撇开涨薪这些外在的 ...

  9. iOS-构建自己的代码块【提高编码效率-Xcode代码块】

    前言 2018年3月1日 农历正月十四 星期四 不知怎么地,一大早上班就想写博客: Xcode代码块 开发中,都不想写过多代码,然后就会用这种方法,去简化代码,包括MVVM框架,它也体现出来了去简化C ...

  10. docker微服务部署之:七、Rancher进行微服务扩容和缩容

    docker微服务部署之:六.Rancher管理部署微服务 Rancher有两个特色用起来很方便,那就是扩容和缩容. 一.扩容前的准备工作 为了能直观的查看效果,需要修改下demo_article项目 ...