2018-08-06 mysql主從備份出現(xiàn)錯(cuò)誤

最近發(fā)現(xiàn)MySQL備份服務(wù)器竟然出現(xiàn)數(shù)據(jù)不同步的問題。

報(bào)錯(cuò)信息:

mysql> show slave status \G

*************************** 1. row ***************************

? ? ? ? ? ? ? Slave_IO_State: Waiting for master to send event

? ? ? ? ? ? ? ? ? Master_Host: 192.168.11.202

? ? ? ? ? ? ? ? ? Master_User: 223backup

? ? ? ? ? ? ? ? ? Master_Port: 3306

? ? ? ? ? ? ? ? Connect_Retry: 60

? ? ? ? ? ? ? Master_Log_File: binlog.000021

? ? ? ? ? Read_Master_Log_Pos: 705618329

? ? ? ? ? ? ? Relay_Log_File: localhost-relay-bin.002879

? ? ? ? ? ? ? ? Relay_Log_Pos: 515550

? ? ? ? Relay_Master_Log_File: binlog.000021

? ? ? ? ? ? Slave_IO_Running: Yes

? ? ? ? ? ? Slave_SQL_Running: No

? ? ? ? ? ? ? Replicate_Do_DB:

? ? ? ? ? Replicate_Ignore_DB: mysql,test

? ? ? ? ? Replicate_Do_Table:

? ? ? Replicate_Ignore_Table:

? ? ? Replicate_Wild_Do_Table:

? Replicate_Wild_Ignore_Table:

? ? ? ? ? ? ? ? ? Last_Errno: 1594

? ? ? ? ? ? ? ? ? Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.

? ? ? ? ? ? ? ? Skip_Counter: 0

? ? ? ? ? Exec_Master_Log_Pos: 676992028

? ? ? ? ? ? ? Relay_Log_Space: 29206302

? ? ? ? ? ? ? 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: 1594

? ? ? ? ? ? ? Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.

? Replicate_Ignore_Server_Ids:

? ? ? ? ? ? Master_Server_Id: 2

1 row in set (0.00 sec)

報(bào)錯(cuò)信息:?Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.

二、原因分析

? ? ? 報(bào)錯(cuò)信息為從庫“無法讀取relay log 里的條目”,可能原因?yàn)閙aster庫的binglog錯(cuò)誤,或slave庫的中繼日志錯(cuò)誤。或者為網(wǎng)絡(luò)問題及bug原因。

? ? ? 一般是由于網(wǎng)絡(luò)故障或slave庫壓力過大,導(dǎo)致relay-log格式錯(cuò)誤造成的。找到當(dāng)前已經(jīng)同步的時(shí)間點(diǎn),重新設(shè)置主從同步,就會(huì)產(chǎn)生新的中繼日志,恢復(fù)正常

三、問題處理

從"show? slave ?status\G"的輸出中,找到如下信息:

Relay_Master_Log_File:? binlog.000021 ? ? //slave庫已讀取的master的binlog

Exec_Master_Log_Pos:?676992028 ? ? ? ? ? //在slave上已經(jīng)執(zhí)行的position位置點(diǎn)

四.問題解決:

停掉slave,以slave已經(jīng)讀取的binlog文件,和已經(jīng)執(zhí)行的position為起點(diǎn),重新設(shè)置同步。會(huì)產(chǎn)生新的中繼日志,問題解決

mysql>stop slave;

mysql>change master to master_log_file='binlog.000021' , master_log_pos=676992028?

//在slave上已經(jīng)執(zhí)行的position位置點(diǎn);

mysql>start slave;

四、驗(yàn)證結(jié)果

再次查看,錯(cuò)誤已經(jīng)解決,slave 開始追 master 的日志

mysql>show ?slave status\G

Exec_Master_Log_Pos: 702086896 ? ? ? ?//slave上已經(jīng)執(zhí)行的position已經(jīng)變化

Seconds_Behind_Master: 79006? ? ? ? ? ? //slave ?落后主庫的時(shí)間,單位秒

過幾秒鐘,再次查看。離與master同步更近了

mysql>show ?slave status\G

Exec_Master_Log_Pos: 703743817

Seconds_Behind_Master: 60672

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1.A simple master-to-slave replication is currently being...
    Kevin關(guān)大大閱讀 6,253評論 0 3
  • MHA是什么? MHA是由日本Mysql專家用Perl寫的一套Mysql故障切換方案,來保障數(shù)據(jù)庫的高可用性,它的...
    張偉科閱讀 743評論 0 1
  • 放手是一種無奈的絕望,痛徹心扉。當(dāng)曾經(jīng)珍愛如生命的人即將相逢陌路時(shí),才恍然大悟:原來,曾經(jīng)以為的天長地久,其實(shí)不過...
    D038_禮恩_佛山閱讀 127評論 0 1
  • 菲菲是某中餐館的服務(wù)員,她做的事情其實(shí)種類也挺多的,因?yàn)槟鞘且患颐娣e不大的餐館,服務(wù)員有三個(gè),廚師兩個(gè),老板...
    洛小簡閱讀 420評論 2 3
  • Linkin Park的主唱走了。講真就是被刷屏之后我也沒能記住他名字,但是卻決定整個(gè)LOGO做紀(jì)念,聽起來是不是...
    請不要叫我小Helen閱讀 368評論 0 0

友情鏈接更多精彩內(nèi)容