Wowking


I don't really know where I'm going, but I hope I go far.


MySQL主从报错1864

简述

MySQL主从报SQL thread stopped

排查

通过show slave status \G看到报错信息:

mysql> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 10.111.111.116
                  Master_User: rep
                  Master_Port: 63306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000047
          Read_Master_Log_Pos: 55033977
               Relay_Log_File: relay-bin.001205
                Relay_Log_Pos: 341059164
        Relay_Master_Log_File: mysql-bin.000046
             Slave_IO_Running: No
            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 /data/logs/mysql/relaylogs/relay-bin.001205, position 341059387 to Worker thread because its size 17796687 exceeds 16777216 of slave_pending_jobs_size_max.
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 861411614
              Relay_Log_Space: 609739624
              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: 0
                Last_IO_Error: 
               Last_SQL_Errno: 1864
               Last_SQL_Error: Cannot schedule event Update_rows, relay-log name /data/logs/mysql/relaylogs/relay-bin.001205, position 341059387 to Worker thread because its size 17796687 exceeds 16777216 of slave_pending_jobs_size_max.
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 105216
                  Master_UUID: ab6e920a-7751-11e6-9ceb-005056b91e33
             Master_Info_File: /data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 171228 15:45:18
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: ab6e920a-7751-11e6-9ceb-005056b91e33:1-47015930
            Executed_Gtid_Set: ab6e920a-7751-11e6-9ceb-005056b91e33:1-47015324,
bfd4cc57-7751-11e6-9ceb-005056b9488a:1-15
                Auto_Position: 1
1 row in set (0.00 sec)

从报错信息看,大概意思是Slave接收到的数据为17796687 B大概为17 M,而slave_pending_jobs_size_max默认大小为16777216
简单说就是Slave接收到的数据超过slave_pending_jobs_size_max参数默认大小。

解决方案

  1. 查看slave_pending_jobs_size_max默认大小:
    mysql> show variables like '%slave_pending_jobs_size_max%';
    +-----------------------------+----------+
    | Variable_name               | Value    |
    +-----------------------------+----------+
    | slave_pending_jobs_size_max | 16777216 |
    +-----------------------------+----------+
    1 row in set (0.00 sec)
    
  2. 修改slave_pending_jobs_size_max大小:
    mysql> set slave_pending_jobs_size_max=16777216*2;
    ERROR 1229 (HY000): Variable 'slave_pending_jobs_size_max' is a GLOBAL variable and should be set with SET GLOBAL
    mysql> set global slave_pending_jobs_size_max=16777216*2;
    Query OK, 0 rows affected (0.00 sec)
    

    tips: slave_pending_jobs_size_max为全局参数。

  3. 重启slave解决:
    mysql> stop slave;
    Query OK, 0 rows affected (0.00 sec)
    mysql> start slave;
    Query OK, 0 rows affected, 1 warning (0.04 sec)
    mysql> show slave status \G
    *************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                   Master_Host: 10.111.105.216
                   Master_User: rep
                   Master_Port: 63306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.000047
           Read_Master_Log_Pos: 55149959
                Relay_Log_File: relay-bin.001205
                 Relay_Log_Pos: 394464185
         Relay_Master_Log_File: mysql-bin.000046
              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: 914816635
               Relay_Log_Space: 609856525
               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: 490
    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: 105216
                   Master_UUID: ab6e920a-7751-11e6-9ceb-005056b91e33
              Master_Info_File: /data/mysql/master.info
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Reading event from the relay log
            Master_Retry_Count: 86400
                   Master_Bind: 
       Last_IO_Error_Timestamp: 
      Last_SQL_Error_Timestamp: 
                Master_SSL_Crl: 
            Master_SSL_Crlpath: 
            Retrieved_Gtid_Set: ab6e920a-7751-11e6-9ceb-005056b91e33:1-47015945
             Executed_Gtid_Set: ab6e920a-7751-11e6-9ceb-005056b91e33:1-47015357:47015359-47015362:47015364-47015368,
    bfd4cc57-7751-11e6-9ceb-005056b9488a:1-15
                 Auto_Position: 1
    1 row in set (0.00 sec)
    

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦