故障描述:

在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大!

最新文章

  1. 彻底理解AC多模式匹配算法
  2. LaTeX test
  3. SQL 高级查询
  4. java 23种设计模式及具体例子 收藏有时间慢慢看
  5. Clarkson不等式
  6. HDOJ--1698
  7. PHP发送短信如何实现?
  8. 深入浅出KnockoutJS
  9. 一道关于call和this的JS面试题
  10. CentOS 7.6环境下安装中文字体库
  11. [模板] 匈牙利算法&&二分图最小字典序匹配
  12. jquery validate 校验时,如果有type=hiddien
  13. 使用Gson将对象类转成Json对象时出现\u003d的问题
  14. python 包和模块
  15. 转:// 再说 Oracle RAC services
  16. [SHOI2008]cactus仙人掌图[圆方树+树dp]
  17. Mybatis进阶学习笔记——关系查询——一对一查询
  18. mysql重装之后 复制data
  19. MySQL登陆小问题
  20. Android调用系统软键盘

热门文章

  1. C盘清理垃圾
  2. 转Git仓库分支(Branch)和标签(Tag)
  3. vue中解决拖动和点击事件的冲突
  4. Ubuntu18.04安装RTX2080Ti+NVIDIA驱动+CUDA
  5. launch-s.sh 发布脚本备份
  6. System.arraycopy复制数组方法解释
  7. Spring知识点整理
  8. ERROR 1872
  9. 2018-2019-2 20175323 实验一《Java开发环境的熟悉》实验报告
  10. (转)Android开发把项目打包成apk