【MySQL故障處理】 Seconds_Behind_Master= NULL Error_code: 1197

來源:互聯網
上載者:User

標籤:mysql   主從中斷   1197   


將處理主從故障的過程記錄在此:

  • 故障1,Error_code: 1197 (max_binlog_cache_size)

資料庫版本:5.7.9

報錯資訊:

[ERROR] Slave SQL for channel ‘‘: Worker 1 failed executing transaction ‘bea4612c-4828-11e7-90b3-a0423f31cad6:716212‘ at master log mysql.135371, end_log_pos 103016490; Could not execute Write_rows event on table ******; Multi-statement transaction required more than ‘max_binlog_cache_size‘ bytes of storage; increase this mysqld variable and try again, Error_code: 1197; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event‘s master log FIRST, end_log_pos 103016490, Error_code: 1197

處理過程:

根據報錯資訊,知道是max_binlog_cache_size小了,

解決辦法:臨時增加該值後restart slave即可以繼續複製線程。

stop slave;set global max_binlog_cache_size= 201326592;start slave;

關於max_binlog_cache_size請看這裡:

如果一個事務需要多於設定值的記憶體,就會報上面的錯。最小4096位元組,最大支援4GB,因為binlog位置點最大4GB,支援動態修改

解決了問題,繼續尋找發生問題的原因,生產環境中的該參數設定為64M,當一個事務影響的資料量超過該值時,即會報錯。

查看主庫中日誌的具體內容:

資料庫日誌格式為mixed,檔案中記錄的是row格式,使用下面命令查看

/bin/mysqlbinlog   -vv --base64-output=decode-rows mysql.135371 | more
精簡後的內容:#  13:43:59 server id *******  end_log_pos 10538 CRC32  Write_rows: table id 2776# at 10538                                          #  13:43:59 server id *******  end_log_pos 18175 CRC32  Write_rows: table id 2776# at 18175                                         #  13:43:59 server id *******  end_log_pos 25789 CRC32  Write_rows: table id 2776# at 25789                                           #  13:43:59 server id *******  end_log_pos 33424 CRC32  Write_rows: table id 2776# at 33424                                            #  13:43:59 server id *******  end_log_pos 40961 CRC32  Write_rows: table id 2776# at 40961                                           #  13:43:59 server id *******  end_log_pos 48553 CRC32  Write_rows: table id 2776# at 48553                                          #  13:43:59 server id *******  end_log_pos 56126 CRC32  Write_rows: table id 2776# at 56126                                          #  13:43:59 server id *******  end_log_pos 63671 CRC32  Write_rows: table id 2776# at 63671                                          #  13:43:59 server id *******  end_log_pos 71205 CRC32  Write_rows: table id 2776# at 71205                                           #  13:43:59 server id *******  end_log_pos 78753 CRC32  Write_rows: table id 2776# at 78753                                           #  13:43:59 server id *******  end_log_pos 86322 CRC32  Write_rows: table id 2776# at 86322                                           #  13:43:59 server id *******  end_log_pos 93925 CRC32  Write_rows: table id 2776

不出意外,執行的sql為

 insert into table1 select * from table2 where time > ‘2016-10-01‘

形式的多語句事務,查看binlog檔案的大小,最大的超過了200M(max_binlog_size設定為50M)。

因此是大事務造成的,大事務還容易造成主從延時的問題,推薦將大事務拆分為小事務執行

107M  14:07 mysql.135380101M  14:08 mysql.135381112M  14:08 mysql.135382110M  14:09 mysql.135383124M  14:09 mysql.135384 31M  14:10 mysql.135385226M  14:10 mysql.135386120M  14:12 mysql.135387111M  14:13 mysql.135388102M  14:14 mysql.135389...126M  14:16 mysql.135394...118M  14:23 mysql.135404...110M  14:28 mysql.135409 63M  14:29 mysql.135410104M  14:29 mysql.135411 281  14:30 mysql.135412115M  14:30 mysql.135413112M  14:30 mysql.135414127M  14:30 mysql.135415119M  14:31 mysql.135416 85M  14:32 mysql.135417 60M  14:32 mysql.135418151M  14:33 mysql.135419

歡迎批評指正

本文出自 “Amnesiasun” 部落格,請務必保留此出處http://amnesiasun.blog.51cto.com/10965283/1931957

【MySQL故障處理】 Seconds_Behind_Master= NULL Error_code: 1197

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.