解決mysql開啟GTID主從同步出現1236錯誤問題【轉】

來源:互聯網
上載者:User

標籤:The   二進位   執行   erro   change   cdc   其他   fat   現象   

最近遇到mysql開啟gtid做複製時,從庫出現1236錯誤,導致同步無法進行,本文就這問題記錄下處理步驟,有關gtid知識在這裡不做介紹,mysql版本為5.7.16。

 

一、錯誤原因分析

錯誤資訊如下:

Last_IO_Errno: 1236

                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.‘

一般兩種情況會出現以上現象

1.在主庫上手動執行清除二進位記錄檔

2.主庫重啟,重新同步時

二、解決方案:

1.在主庫上執行以下命令,查詢gtid_purged,記錄下改值

mysql> show global variables like ‘%gtid%‘\G

2.在從庫上執行以下命令,查詢已經執行過的gtid即gtid_executed,記錄下主庫的值,原生不需要

3.在從庫上執行以下命令停止同步線程及重設同步相關資訊

mysql> stop slave;

mysql> reset slave;

mysql> reset master;

4.在從庫上設定gtid_purged

該值有兩個來源,一是在主庫上查詢的gtid_purged,二是在從庫上查詢的已經執行過的gtid_executed值(原生就不需要,主庫上gtid)

注意:一定記得加上從庫上已經執行過的gtid,若只設定了主庫上的gtid_purged,此時從庫會重新拉取主庫上所有的二進位記錄檔,同步過程會出現其他錯誤,導致同步無法進行

mysql> set @@global.gtid_purged=‘4fa9ab33-3077-11e6-8ee6-fcaa14d0751b:1-18240458,6e41a42e-8529-11e6-b72e-fcaa14d07546:1-56604052:56604054-56605629:56605631-56871196,9850e381-b601-11e6-8e46-fcaa14d07546:1-3126210,c5cdcae2-9cb0-11e6-909c-fcaa14d0751b:1-1189,10a59961-c02d-11e6-a2de-fcaa14d07546:1-13381418‘;

注意:設定gtid_purged值時,gtid_executed值必須為空白否則報錯,該值清空的方法就是reset  master命令

執行完,再次查看相關資訊

5.重新開啟同步

 

mysql> change master to master_host=‘192.168.1.15‘,master_port=3306,master_user=‘repl‘,master_password=‘xxx‘,master_auto_position=1;

mysql>  start slave;

當從庫追趕上主庫,此時測試主從資料是否一致,測試結果一切正常

mk-table-checksum h=192.168.1.15,u=root,p=xxx,P=3306 h=192.168.1.19,u=root,p=xxxx,P=3307 -d 6coursestudychoose_test | mk-checksum-filter

 

轉自

解決mysql開啟GTID主從同步出現1236錯誤問題-linux之路-51CTO部落格

http://blog.51cto.com/hnr520/1883282

解決mysql開啟GTID主從同步出現1236錯誤問題【轉】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.