監控mysql各種選項

來源:互聯網
上載者:User

標籤:thread   nes   master   user   query   串連   and   soc   uptime   

安裝mysql之後,需要對mysql服務進行監控。

 nagios開源內建的check_mysql 對 mysql 的slave 機監控倒是不錯。但是對資料庫主機監控就略顯不足了。 使用一個監控外掛程式:check_mysql_health 下載和使用方法見: http://exchange.nagios.org/directory/MySQL/check_mysql_health/details 具體監控: 對於slave 機 ,使用nagios 內建的 check_mysql 監控 command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql -H localhost -s /tmp/mysql.sock -u root -p xxx -S -w 1 -c 3 其中使用者和密碼有可能會更改。延遲1秒警告,延遲3秒警示。 check_mysql_health 監控mysql master 伺服器 /usr/local/nagios/libexec/custom/check_mysql_health --hostname localhost --socket /tmp/mysql.sock --username root --password xxxxxx --mode xxxxx --warning xxxxx --criticalxxxxx mode:

connection-time (Time to connect to the server) 

uptime (Time the server is running) 

threads-connected (Number of currently open connections) 

threadcache-hitrate (線程快取命中率) 

slave-lag (Seconds behind master) 

slave-io-running (Slave io running: Yes) 

slave-sql-running (Slave sql running: Yes) 

qcache-hitrate (查詢命中率,如果這個值接近100%,說明伺服器select的最佳化就越好) 

qcache-lowmem-prunes (因為記憶體小,從記憶體刪除緩衝查詢的數量,可以增大query_cache_size,減小lowmem,增加命中率的最佳化) 

keycache-hitrate (MyISAM key 快取命中率,如果命中率太低,增大key_buffer_size) 

bufferpool-hitrate (InnoDB 緩衝池命中率) 

bufferpool-wait-free (InnoDB 緩衝池等待清理的頁面) 

log-waits (InnoDB log 等待寫入時間,如果這個等待時間太大,增大log緩衝池大小) 

tablecache-hitrate (Table 快取命中率) 

table-lock-contention (Table 的lock率) 

index-usage (索引使用率,越大說明索引越好,越小說明索引最佳化不充分) 

tmp-disk-tables (暫存資料表建立的數量) 

slow-queries (慢查詢占所有查詢的比率,這個值如果很高說明mysql資料庫最佳化不夠) 

long-running-procs (長期啟動並執行進程) 

cluster-ndbd-running (mysql叢集監控) 

sql (執行一個返回一個數位SQL,檢查mysql是否可以連結查詢)

 舉例:nrpe.cfg:command[check_mysql_health]=/usr/local/nagios/libexec/custom/check_mysql_health --hostname localhost --socket /tmp/mysql.sock --username xxxxx --password xxxxx --mode $ARG1$ --warning $ARG2$ --critical $ARG3$  xxx.cfg:define service{        use                     xxxxxx        host_name               xxxxxx        service_description     mysql資料庫連接數        check_command           check_nrpe_args!check_mysql_health!threads-connected!80!120} define service{        use                     xxxxx        host_name               xxxxx        service_description     mysql資料庫innodb快取命中        check_command           check_nrpe_args!check_mysql_health!bufferpool-hitrate}define service{        use                     xxxxx        host_name               xxxxx        service_description     mysql資料庫innodb緩衝池等待清理的頁        check_command           check_nrpe_args!check_mysql_health!bufferpool-wait-free}define service{        use                     xxxxx        host_name               xxxxx        service_description     mysql資料庫innodblog寫入等待時間        check_command           check_nrpe_args!check_mysql_health!log-waits}define service{        use                     xxxxx        host_name               xxxxx                                                                                           service_description     mysql資料庫鎖表率        check_command           check_nrpe_args!check_mysql_health!table-lock-contention}define service{        use                     xxxxx                                                                                          host_name               xxxxx        service_description     mysql資料庫開啟檔案數        check_command           check_nrpe_args!check_mysql_health!open-files!80!90}define service{        use                     xxxxx                                                                                         host_name               xxxxx        service_description     mysql資料庫慢查詢率        check_command           check_nrpe_args!check_mysql_health!slow-queries!5!10} 搞定。 PS:對 warnging 和 critical 的值 :  10 就是 大於10%警示, 10: 就是小於10%警示, 不填就是預設的數值。mode 一個語句只能一個, --mode xxx1  xxx2    : xxx1 生效--mode xxx1  --mode xxx2  : xxx2 生效

監控mysql各種選項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.