故障描述:

在mysql 主库上增加了一个主键操作,没过5分钟就接受到zabbix报警mysql主从同步异常停止信息,一首凉凉送给自己。。。。

查看现在主从状态

(root@192.168.1.2) [(none)]> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error: Cannot schedule event Update_rows, relay-log name ./log-relaynew., position to Worker thread because its size exceeds of slave_pending_jobs_size_max. #从last_sql_error 错误信息,可以看出是因为slave_pending_jobs_size_max 值引起的,默认值16777216,但是接收到的是16777713,所以导致主从同步停止。

处理步骤如下:

1、查看主库max_allowed_packet的大小

(root@192.168.1.1) [(none)]> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | |
+--------------------+----------+
row in set (0.00 sec)

2、设置从库slave_pending_jobs_size_max的大小,注意,需要大于主库max_allowed_packet的大小

(root@192.168.1.2) [(none)]> stop slave;
Query OK, 0 rows affected (0.00 sec)
(root@192.168.1.2) [(none)]> set global slave_pending_jobs_size_max=52428800;
Query OK, rows affected, warning (0.00 sec)

(root@192.168.1.2) [(none)]> show variables like '%slave_pending_jobs%';
  +-----------------------------+----------+
  | Variable_name | Value |
  +-----------------------------+----------+
  | slave_pending_jobs_size_max | 52428800 |
  +-----------------------------+----------+
  1 row in set (0.01 sec)

(root@192.168.1.2) [(none)]> start slave;
Query OK, 0 rows affected (0.01 sec)

3、查看主从同步状态

(root@192.168.1.2) [(none)]> show slave status\G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.1
Master_User: repl
Master_Port:
Connect_Retry:
Master_Log_File: log-bin.
Read_Master_Log_Pos:
Relay_Log_File: log-relaynew.
Relay_Log_Pos:
Relay_Master_Log_File: log-bin.
Slave_IO_Running: Yes
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:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 872aba0b-b543-11e6-9ce1-0cc47a581d8c
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 872aba0b-b543-11e6-9ce1-0cc47a581d8c:-
Executed_Gtid_Set: 1bf68f85-ef7c-11e8-bad9-0cc47abcef86:-,
872aba0b-b543-11e6-9ce1-0cc47a581d8c:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
row in set (0.00 sec)

搞定!!

Tips:

slave_pending_jobs_size_max的用途:
在多线程复制时,在队列中Pending的事件所占用的最大内存,默认为16M,如果内存富余,或者延迟较大时,可以适当调大;注意这个值要比主库的max_allowed_packet大!

Mysql 1864 主从错误解决方法的更多相关文章

  1. 安装Mysql提示1045错误解决方法

    MySQL安装提示一下错误 The security settings could not be applied to the database because the connection has ...

  2. MySQL or MariaDB 错误解决方法之报错代码1045

    phpMyAdmin登录报错:mysqli_real_connect(): (28000/1045): Access denied for user 'root'@'localhost' (using ...

  3. 解决mysql 1864 主从错误

     从字面意思看了一下是因为slave_pending_jobs_size_max默认值为16777216(16MB),但是slave接收到的slave_pending_jobs_size_max为 ...

  4. django中mysql数据库设置错误解决方法

    刚在django中settings.py进行设置mysql数据库. 当进行执行python manage.py shell命令时会报以下错误: 只需要在settings.py中 DATABASES = ...

  5. MySQL的1067错误解决方法

    今天在学校的时候MySQL还运行的好好的,关机来公司后MySQL一直报错,错误为1067,网上找了好多办法,但是大都没效果,因此对这个错误做个总结: 打开你的安装目录下,查看my.ini文件中MySQ ...

  6. mysql Access denied for user root@localhost错误解决方法总结(转)

    mysql Access denied for user root@localhost错误解决方法总结(转) mysql Access denied for user \'root\'@\'local ...

  7. MySQL程序端启动密码错误解决方法

    MySQL程序端启动密码错误解决方法 一般启动MySQL程序端,都是用mysql -uroot -p命令,当然前提是你的环境变量已经配好了. 为了连接服务器,当调用mysql时,通常需要提供一个MyS ...

  8. mysql创建外链失败1005错误解决方法

    mysql创建外链失败1005错误解决方法 错误号:1005错误信息:Can't create table 'webDB.#sql-397_61df' (errno: 150)解决方法 错误原因有四: ...

  9. 3分钟解决MySQL 1032 主从错误(转)

    转自  https://blog.51cto.com/suifu/1845457 3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了, ...

随机推荐

  1. Git 学习(二)Git 基础

    Git 基础 Git 在保存和对待各种信息的时候与其它版本控制系统如 SVN 等等有很大差异,尽管操作起来的命令形式非常相近,理解这些差异将有助于防止你使用中的困惑. Git 记录的是什么? 如果有使 ...

  2. error C1083: 无法打开包括文件: “ui_roadquery.h”: No such file or directory c:\users\administrator\desktop\g_w_j\04 开发阶段\开发工程\imcshowapp\imcshowapp\roadquery.h 5 1 IMCShowApp

    1.我这里出现的原因是忘记将项目文件添加进入项目中,在项目中右击添加即可

  3. CSS3教程:Responsive框架常见的Media Queries片段

    CSS3 Media Queries片段在这里主要分成三类:移动端.PC端以及一些常见的响应式框架的Media Queries片段.移动端Media Queries片段iPhone5@media sc ...

  4. scala中闭包的使用

    闭包的实质就是代码与用到的非局部变量的混合,即: 闭包 = 代码 + 用到的非局部变量 实例1: 匿名函数中引入闭包 val multiplier = (i:Int) => i * factor ...

  5. Spring Boot 整合 Shiro+Thymeleaf

    1.导包 <!-- springboot 与 shiro 的集成--> <dependency> <groupId>org.apache.shiro</gro ...

  6. 转——调试寄存器 原理与使用:DR0-DR7

    下面介绍的知识性信息来自intel IA-32手册(可以在intel的开发手册或者官方网站查到),提示和补充来自学习调试器实现时的总结. 希望能给你带去有用的信息. (DRx对应任意的一个调试寄存器. ...

  7. 2019-6-23-win10-uwp-开发-CSDN-访问量统计-源代码

    title author date CreateTime categories win10 uwp 开发 CSDN 访问量统计 源代码 lindexi 2019-6-23 11:2:1 +0800 2 ...

  8. YARN设计思路

  9. python库之sklearn

     一.安装sklearn conda install scikit-learn 参考文献 [1]整体介绍sklearn https://blog.csdn.net/u014248127/article ...

  10. Ubuntu Apache vhost不执行php小记

    运行环境: Ubuntu : 16.04 PHP: 5.6.36 Apache: 2.4.18 出现/var/www/html 文件夹下的 php文件能够执行 vhost 配置文件的DocumentR ...