收到監控簡訊,說更新和插入閥值警示,於是登陸mysql-monitor上查看,確實如此,
650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/19412211N-0.jpg" alt="" />
登陸mysql伺服器上,通過binlog分析,17:05之前和之後的,看是哪個表更新較大。
[root@XXX-02 logs]# mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.053373 |more
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#120802 16:36:47 server id 4713306 end_log_pos 106 Start: binlog v 4, server v 5.1.43sp1-br38368-enterprise-gpl-pro-log c
reated 120802 16:36:47
然後用這條命令分析,得出寫操作頻繁的表
[root@XXX-02 logs]# mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.053373 |awk '/###/{if($0~/UPDATE|INSERT|DELETE/)count[$2" "$NF]++}END{for(i in count)print i,"\t",count[i]}' | column -t | sort -k3nr | more
UPDATE DB.Dynamic 133971
UPDATE DB.User 54834
UPDATE DB.Quota 24938
UPDATE DB.OrderHistory 24482
UPDATE DB.BOSSOperation 19767
UPDATE DB.SmsCount 18235
UPDATE DB.Buddy 10919
INSERT DB.Buddy_Log 10024
=====================================================================
接著查看17:05之後的binlog日誌。
[root@XXX-02 logs]# mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.053375 |more
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#120802 17:10:54 server id 4713306 end_log_pos 106 Start: binlog v 4, server v 5.1.43sp1-br38368-enterprise-gpl-pro-log c
reated 120802 17:10:54
# at 106
然後用這條命令分析,得出寫操作頻繁的表
[root@XXX-02 logs]# mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.053375 |awk '/###/{if($0~/UPDATE|INSERT|DELETE/)count[$2" "$NF]++}END{for(i in count)print i,"\t",count[i]}' | column -t | sort -k3nr
INSERT DB.Buddy_Log 194160
INSERT DB.Buddy 192587
UPDATE DB.Dynamic 62767
UPDATE DB.User 30103
UPDATE DB.OrderHistory 12507
UPDATE DB.Quota 12318
UPDATE DB.BOSSOperation 9892
這樣比較直觀的顯示出哪些表更新較多,然後找開發確認問題,是否是業務增長導致。
本文出自 “賀春暘的技術專欄” 部落格,請務必保留此出處http://hcymysql.blog.51cto.com/5223301/951613