国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL中slave監控的延遲情況分析

2024-07-24 12:46:11
字體:
來源:轉載
供稿:網友

在MySQL復制環境中,我們通常只根據 Seconds_Behind_Master 的值來判斷SLAVE的延遲。這么做大部分情況下尚可接受,但并不夠準確,而應該考慮更多因素。

首先,我們先看下SLAVE的狀態:

復制代碼 代碼如下:
yejr@imysql.com [(none)]> show slave status/G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
***
Master_Log_File: mysql-bin.000327
Read_Master_Log_Pos: 668711237
Relay_Log_File: mysql-relay-bin.002999
Relay_Log_Pos: 214736858
Relay_Master_Log_File: mysql-bin.000327
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
***
Skip_Counter: 0
Exec_Master_Log_Pos: 654409041
Relay_Log_Space: 229039311
***
Seconds_Behind_Master: 3296
***

可以看到 Seconds_Behind_Master 的值是 3296,也就是SLAVE至少延遲了 3296 秒。

我們再來看下SLAVE上的2個REPLICATION進程狀態:

復制代碼 代碼如下:
yejr@imysql.com [(none)]> show full processlist/G
*************************** 1. row ***************************
Id: 6
User: system user
Host:
db: NULL
Command: Connect
Time: 22005006
State: Waiting for master to send event
Info: NULL
*************************** 2. row ***************************
Id: 7
User: system user
Host:
db: NULL
Command: Connect
Time: 3293
State: Updating
Info: UPDATE ** SET ** WHERE **

可以看到SQL線程一直在執行UPDATE操作,注意到 Time 的值是 3293,看起來像是這個UPDATE操作執行了3293秒,一個普通的SQL而已,肯定不至于需要這么久。
實際上,在REPLICATION進程中,Time 這列的值可能有幾種情況:
1、SQL線程當前執行的binlog(實際上是relay log)中的timestamp和IO線程最新的timestamp的差值,這就是通常大家認為的 Seconds_Behind_Master 值,并不是某個SQL的實際執行耗時;
2、SQL線程當前如果沒有活躍SQL在執行的話,Time值就是SQL線程的idle time;

而IO線程的Time值則是該線程自從啟動以來的總時長(多少秒),如果系統時間在IO線程啟動后發生修改的話,可能會導致該Time值異常,比如變成負數,或者非常大。

來看下面幾個狀態:

#設置pager,只查看關注的幾個status值yejr@imysql.com [(none)]> pager cat | egrep -i 'system user|Exec_Master_Log_Pos|Seconds_Behind_Master|Read_Master_Log_Pos'#這是沒有活躍SQL的情況,Time值是idle time,并且 Seconds_Behind_Master 為 0yejr@imysql.com [(none)]> show processlist; show slave status/G| 6 | system user | | NULL | Connect | 22004245 | Waiting for master to send event | NULL || 7 | system user | | NULL | Connect | 13 | Has read all relay log;**Read_Master_Log_Pos: 445167889Exec_Master_Log_Pos: 445167889Seconds_Behind_Master: 0#和上面一樣yejr@imysql.com [(none)]> show processlist; show slave status/G| 6 | system user | | NULL | Connect | 22004248 | Waiting for master to send event | NULL || 7 | system user | | NULL | Connect | 16 | Has read all relay log;**Read_Master_Log_Pos: 445167889Exec_Master_Log_Pos: 445167889Seconds_Behind_Master: 0#這時有活躍SQL了,Time值是和 Seconds_Behind_Master 一樣,即SQL線程比IO線程“慢”了1秒yejr@imysql.com [(none)]> show processlist; show slave status/G| 6 | system user | | NULL | Connect | 22004252 | Waiting for master to send event | NULL || 7 | system user | | floweradmin | Connect | 1 | Updating | update **Read_Master_Log_Pos: 445182239Exec_Master_Log_Pos: 445175263Seconds_Behind_Master: 1#和上面一樣yejr@imysql.com [(none)]> show processlist; show slave status/G| 6 | system user | | NULL | Connect | 22004254 | Waiting for master to send event | NULL || 7 | system user | | floweradmin | Connect | 1 | Updating | update **Read_Master_Log_Pos: 445207174Exec_Master_Log_Pos: 445196837Seconds_Behind_Master: 1
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吐鲁番市| 耒阳市| 黄大仙区| 长汀县| 惠水县| 巨鹿县| 平邑县| 祁门县| 长春市| 儋州市| 颍上县| 紫阳县| 巴彦县| 巴楚县| 徐水县| 卢龙县| 天全县| 九龙县| 边坝县| 双桥区| 西和县| 赞皇县| 柳河县| 洛宁县| 射阳县| 伽师县| 珲春市| 晋宁县| 星座| 峡江县| 项城市| 隆德县| 永和县| 水富县| 石河子市| 昂仁县| 涟水县| 瑞昌市| 从化市| 馆陶县| 深州市|