溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MySQL中second behind master不準(zhǔn)確怎么處理

發(fā)布時(shí)間:2021-11-02 15:08:32 來(lái)源:億速云 閱讀:282 作者:小新 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章主要為大家展示了“MySQL中second behind master不準(zhǔn)確怎么處理”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“MySQL中second behind master不準(zhǔn)確怎么處理”這篇文章吧。

    binglog日志中event的event header(event header的前4個(gè)字節(jié))記錄了event的時(shí)間戳,SQL回放的時(shí)間減去這個(gè)event產(chǎn)生的時(shí)間,就是Seconds_Behind_Master的時(shí)間。但是這個(gè)時(shí)間不準(zhǔn)確,線上有時(shí)延時(shí)是幾千秒(3600s),但是突然就變成了0,有這種情況。


pt-heartbeat,下載通用二進(jìn)制包

MySQL中second behind master不準(zhǔn)確怎么處理

創(chuàng)建監(jiān)控?cái)?shù)據(jù)庫(kù):

mysql> create database monitor;
Query OK, 1 row affected (0.02 sec)

下載安裝
./pt-heartbeat -D monitor --update -uroot -p oracle -P3306 -h 10.10.60.60 --create-table --daemonize

參數(shù)的意義:

  • --update表示要實(shí)時(shí)更新時(shí)間戳的數(shù)據(jù),這就是和之前的seconds_behind_master不同,seconds_behind_master并不是實(shí)時(shí)更新。

  • --daemonize放到后臺(tái)執(zhí)行

  • --create-table第一次需要?jiǎng)?chuàng)建heartbeat名的表。

    MySQL中second behind master不準(zhǔn)確怎么處理
    pt-heartbeat創(chuàng)建一個(gè)帶有時(shí)間戳的表,并且因?yàn)槭侵鲝模@樣表會(huì)復(fù)制到從上。

并且我們可以看到,每次查詢的時(shí)候時(shí)間戳和position都是變化的,
備庫(kù)上heartbeat表的ts列時(shí)間和主庫(kù)heartbeat表中ts列的時(shí)間差就是主從復(fù)制的延遲時(shí)間
并且工具中還提供了monitor監(jiān)控工具。

監(jiān)控:

./pt-heartbeat -D monitor --monitor --master-server-id  603306 -uroot -p oracle -P3306 -h 10.10.60.60

MySQL中second behind master不準(zhǔn)確怎么處理

看精確的看第一列,后幾列分別為1min、5min、15min內(nèi)的延遲時(shí)間。

以上是“MySQL中second behind master不準(zhǔn)確怎么處理”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI