mysql 缓存监控_MySQL监控性能的一些方法总结
---首先, Oracle中的邏輯讀對應物理讀的概念,是在利用數據緩存區的技術上,對數據訪問次數的計數分類。---物理讀,真正有IO;邏輯讀,是從緩存區讀到數據,可以考察緩存區的命中率,但只是某個具體對象在緩存區中的命中率。---所以,使用數據緩存區技術的,都可以有類似的方式。但是,這僅是從IO的角度去衡量數據庫的性能的。即不完全可靠。---其次,MySQL提供了一些方式,用以考察IO的使用情況。---MySQL方式1:區分“索引讀”還是“隨機讀”。這種情況,不從緩存區的角度出發,是從單表掃描數據的方式的角度出發的。---所以,可以采用如下方式輔助判斷:mysql> show status like 'handler_read%';+-----------------------+-------+| Variable_name???????? | Value |+-----------------------+-------+| Handler_read_first??? | 0???? || Handler_read_key????? | 2???? || Handler_read_last???? | 0???? || Handler_read_next???? | 0???? || Handler_read_prev???? | 0???? || Handler_read_rnd????? | 0???? || Handler_read_rnd_next | 0???? |+-----------------------+-------+7 rows in set (0.00 sec)---MySQL方式2:通過狀態變量了解服務器整體狀況---通過show status和應用特點了解各種sql的執行頻率---通過show status可以提供服務器狀態信息,如以下幾個參數對MyISAM和Innodb存儲引擎都計數:1、com_select:執行select操作的計數,一次查詢只累加1;2、com_insert:執行insert操作的次數,對于批量插入的insert操作,只累加一次;3、com_update:執行update操作的次數;4、com_delete:執行delete操作的次數;---以下幾個參數是針對Innodb存儲引擎計數的,累加的算法也略有不同:1、Innodb_rows_read:查詢返回的行數,不僅是select操作,delete和update也會觸發對元組的讀操作;2、Innodb_rows_inserted:執行insert操作插入的行數;3、Innodb_rows_updated:執行update操作更新的行數;4、Innodb_rows_deleted:執行delete 操作刪除的行數;通過以上幾個參數,使用show status 命令查看參數值,就可以很容易了解當前數據庫的應用是以插入更新為主還是查詢操作為主,對于更新操作的計數,是對執行次數的計數,不論成功提交還是回滾都會累加。對于事務型的應用,可以通過com_commit和com_rollback可以了解事務提交和回滾的情況,對于回滾操作非常頻繁的數據庫,可能意味著存在應用編寫問題。---MySQL方式3:通過PFS(Performance Schema)了解服務器整體狀況/IO狀況1、The MySQL Performance Schema is a feature for monitoring MySQL Server execution at a low level.2、The Performance Schema monitors server events. An “event” is anything the server does that takes time and has been instrumented so that timing information can be collected. In general, an event could be a function call, a wait for the operating system, a stage of an SQL statement execution such as parsing or sorting, or an entire statement or group of statements. Currently, event collection provides access to information about synchronization calls (such as for mutexes) file and table I/O, table locks, and so forth for the server and for several storage engines.3、這個功能很強大, 請大家注意掌握. 內容多我們不一一說明,可以參考官方手冊的performance-schema.htm文件. 他必定要成為MySQL監控的主流.
總結
以上是生活随笔為你收集整理的mysql 缓存监控_MySQL监控性能的一些方法总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 注入用例_mysql-常用注
- 下一篇: mysql包1166_mysql 错误