码迷,mamicode.com
首页 > 数据库 > 详细

Mysql 1864 主从错误解决方法

时间:2019-01-25 17:40:01      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:gtid   t_sql   erro   event   内存   schedule   date   tin   pac   

故障描述:

在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: 1864
                   Last_Error: Cannot schedule event Update_rows, relay-log name ./log-relaynew.000867, position 93464188 to Worker thread because its size 16777713 exceeds 16777216 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 | 33554432 |
+--------------------+----------+
1 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, 0 rows affected, 1 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
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.1
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: log-bin.001101
          Read_Master_Log_Pos: 210990225
               Relay_Log_File: log-relaynew.000869
                Relay_Log_Pos: 1111040
        Relay_Master_Log_File: log-bin.001101
             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: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 210985256
              Relay_Log_Space: 3648409
              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: 141
                  Master_UUID: 872aba0b-b543-11e6-9ce1-0cc47a581d8c
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 872aba0b-b543-11e6-9ce1-0cc47a581d8c:532748990-581195316
            Executed_Gtid_Set: 1bf68f85-ef7c-11e8-bad9-0cc47abcef86:1-28,
872aba0b-b543-11e6-9ce1-0cc47a581d8c:1-581195316
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

搞定!!

Tips:

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

 

Mysql 1864 主从错误解决方法

标签:gtid   t_sql   erro   event   内存   schedule   date   tin   pac   

原文地址:https://www.cnblogs.com/gaibianziji/p/10320283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!