![mysql運行監(jiān)控_第1頁](http://file4.renrendoc.com/view/94b66d0951fdc4a142ce049933e3bb01/94b66d0951fdc4a142ce049933e3bb011.gif)
![mysql運行監(jiān)控_第2頁](http://file4.renrendoc.com/view/94b66d0951fdc4a142ce049933e3bb01/94b66d0951fdc4a142ce049933e3bb012.gif)
![mysql運行監(jiān)控_第3頁](http://file4.renrendoc.com/view/94b66d0951fdc4a142ce049933e3bb01/94b66d0951fdc4a142ce049933e3bb013.gif)
![mysql運行監(jiān)控_第4頁](http://file4.renrendoc.com/view/94b66d0951fdc4a142ce049933e3bb01/94b66d0951fdc4a142ce049933e3bb014.gif)
![mysql運行監(jiān)控_第5頁](http://file4.renrendoc.com/view/94b66d0951fdc4a142ce049933e3bb01/94b66d0951fdc4a142ce049933e3bb015.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、 MySQL Monitoring ChinaUnix網(wǎng)友技術(shù)交流 曹金成 NetSeekEmail:- 2009-3-281 MySQL Monitoring 一、如何有效監(jiān)控?監(jiān)控的目的 二、基本監(jiān)控解決方案(基礎(chǔ)數(shù)據(jù)收集) 三、高級解決方案(數(shù)據(jù)庫健康狀態(tài),優(yōu)化) 四、MySQL性能相關(guān)交互式監(jiān)控工具 五、相關(guān)資源參考2 一 、如何有效監(jiān)控?一、如何有效監(jiān)控?監(jiān)控的目的? 1 、服務(wù)健康監(jiān)測(存活,故障告警.) 2 、監(jiān)控系統(tǒng)采集數(shù)據(jù),依據(jù)數(shù)據(jù)進行調(diào)優(yōu) 3 二、 基本監(jiān)控解決方案二、基本監(jiān)控解決方案(收集系統(tǒng)信息) top 、vmstat 、iostat 、mpstat 、mytop 、
2、dstata 、free 、/proc/. 、mstat 、mtop .命令行工具分析系統(tǒng)資源使用狀況.4 三、高級監(jiān)控解決方案 三、高級監(jiān)控解決方案 1、Nagios相關(guān):(收集數(shù)據(jù)庫信息及健康狀態(tài),對數(shù)據(jù)庫調(diào)整優(yōu)化) check_mysql 推薦 nagios-mysql-plugins-0.3 適當選擇 check_mysql_health 重點介紹推薦 由于時間關(guān)系本PPT只重點介紹一下Nagios相關(guān)的插件腳本. 重點介紹一下check_mysql_health監(jiān)控數(shù)據(jù)庫調(diào)優(yōu)。 2、MySQL Activity Report 基于rrdtool * * 演示網(wǎng)站5 三、高級監(jiān)控解決方
3、案 三、高級監(jiān)控解決方案 3、CACTI * MySQL模板: 4、RRD 參考資料: * * * * 5、Munin * .6 Nagios check_mysql #cd /usr/local/nagios/libexec/ # ./check_mysql help /查看使用說明Usage: check_mysql -d database -H host -P port -s socket -u user -p password -SOptions: -h, -help Print detailed help screen -V, -version Print version infor
4、mation -H, -hostname=ADDRESS Host name, IP Address, or unix socket (must be an absolute path) -P, -port=INTEGER Port number (default: 3306) -s, -socket=STRING Use the specified socket (has no effect if -H is used) -d, -database=STRING Check database with indicated name -u, -username=STRING Connect u
5、sing the indicated username -p, -password=STRING Use the indicated password to authenticate the connection = IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE! grant all privileges - on *.* - to identified by linuxtone;Query OK, 0 rows affected (0.00 sec)mysql flush privileges;Query OK, 0 rows af
6、fected (0.00 sec)8 Nagios check_mysql示例:在監(jiān)控機上.#cd /usr/local/nagios/libexec/連接204查看數(shù)據(jù)庫狀態(tài):#./check_mysql -H 192.168.169.204 -u netseek -p linuxtoneUptime: 2146510 Threads: 1 Questions: 61155591 Slow queries: 325 Opens: 1273 Flush tables: 1 Open tables: 767 Queries per second avg: 28.491連接數(shù)據(jù)庫123查看./ch
7、eck_mysql -H 192.168.169.123 -u netseek -p linuxtone -S -w 60 -c 600Uptime: 35349 Threads: 1 Questions: 4022 Slow queries: 0 Opens: 38 Flush tables: 1 Open tables: 32 Queries per second avg: 0.114 Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0OK,在命令行下都能正常連接數(shù)據(jù)庫:9Check_mysql Nagios配置# vi comman
8、ds.cfg 添加如下:#check_mysqldefine command command_name check_mysql command_line $USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ /仔細看參數(shù)傳遞與上面的命令行對應(yīng). #check_slavedefine command command_name check_slave command_line $USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -S -w $ARG5$ -c $AR
9、G6$ 10Check_mysql Nagios配置#vi sh-wt- 給上海網(wǎng)通兩臺DB服務(wù)器配置上mysql數(shù)據(jù)庫檢測: 在自己定的的配置文件里,添加如下服務(wù)段.#check_mysqldefine service host_name dbss-master service_description check_mysql check_command check_mysql!192.168.169.122!3306!netseek!linuxtone #check slavedefine service host_name dbss-slave service_description ch
10、eck_slave check_command check_slave!192.168.169.123!3306!netseek!linuxtone!60!600 11 Nagios check_mysqlcheck_mysql監(jiān)控演示效果Check_mysql S 模塊可以很好的檢測mysql replication slave的健康狀態(tài).mysqlshow slave stautsG*是否工作 Slave_IO_running: YES Slave_SQL_running: YES*延遲情況 Sencodes_behind_master12 nagios-mysql-plugins選擇性的
11、使用此插件來配合監(jiān)控工作# wget # tar zxvf nagios-mysql-plugins-0.3.tar.gz# cd nagios-mysql-plugins-0.3# chmod a+x *# mv * /usr/local/nagios/libexec插件解釋:check_db_mysql.pl 檢測mysql是否運行.check_errorlog_mysql.pl 檢測數(shù)據(jù)庫下的錯誤日志perf_mysql.pl 收集性能數(shù)據(jù),類似后面要講的check_mysql_healthreplication相關(guān).check_repl_mysql_cnt_slave_hosts.pl
12、 /檢測復(fù)制相關(guān)。check_repl_mysql_hearbeat.plcheck_repl_mysql_io_thread.plcheck_repl_mysql_read_exec_pos.plcheck_repl_mysql_readonly.plcheck_repl_mysql_seconds_behind_master.plcheck_repl_mysql_sql_thread.pl13 nagios-mysql-plugins./check_db_mysql.pl -h 192.168.169.204 -u netseek -p linuxtone -port 3306編寫comm
13、and define command command_name check_db_mysql command_line $USER1$/check_db_mysql.pl -h $ARG1$ -u $ARG2$ -p $ARG3$ -port $ARG4$ 服務(wù)端配置: check_command check_db_mysql!192.168.169.204!netseek!linuxtone!3306 14 check_mysql_health 一、安裝check_mysql_health 官方網(wǎng)站: # wget # tar zxvf check_mysql_health-2.0.3.ta
14、r.gz # cd check_mysql_health-2.0.3 # ./configure -prefix=/usr/local/nagios -with-nagios-user=nagios - with-nagios-group=nagios -with-perl -with-state # make & make install 注:check_mysql_health (check_mysql_perf的替代方案,官方不再支持 check_mysql_perf) 詳細參見: 15 check_mysql_health二、check_mysql_health 插件使用說明 # cd
15、 /usr/local/nagios/libexec/ # ./check_mysql_health -help Check various parameters of MySQL databases Usage: check_mysql_health -v -t -hostname -port | -socket -username -password -mode -method mysql check_mysql_health -h | -help check_mysql_health -V | -version 16 check_mysql_health . Options: -host
16、name the database servers hostname -port the databases port. (default: 3306) -socket the databases unix socket. -username the mysql db user -password the mysql db users password -database the databases name. (default: information_schema) -warning the warning range -critical the critical range 17 che
17、ck_mysql_health .-mode the mode of the plugin. select one of the following keywords: connection-time (Time to connect to the server) 連接到服務(wù)器的時間. uptime (Time the server is running) MySQL服務(wù)器運行的時間 threads-connected (Number of currently open connections) 數(shù)據(jù)庫服器當前打開的連接 threadcache-hitrate (Hit rate of the
18、 thread-cache) 線程緩存命中率 mysql replication 相關(guān)段 slave-lag (Seconds behind master) 判斷slave落后于master多少秒 slave-io-running (Slave io running: Yes) 表明Slave復(fù)制正常運行 slave-sql-running (Slave sql running: Yes) 表明Slave復(fù)制正常運行 用check_mysql 模塊來替代這些功能更,check_mysql是用C寫的執(zhí)行速度更快. -check-slave ./check_mysql -H 192.168.169
19、.123 -u netseek -p linuxtone -S 來解決18 check_mysql_health. 查詢緩存相關(guān) qcache-hitrate (Query cache hitrate) 查詢命中率,這個比率越高則表明服務(wù)器的SELECT 查詢性能就越好 qcache-lowmem-prunes (Query cache entries pruned because of low memory) 由于內(nèi)存較小從緩存刪除的查詢數(shù)量 增大query_cache_size的值,以減小lowmem,增加緩存命中率 keycache-hitrate (MyISAM key cache h
20、itrate)n key緩存命中率 如果命中率低,則調(diào)大key_buffer_size InnoDB Cache命中率 bufferpool-hitrate (InnoDB buffer pool hitrate) Innodb 緩沖池命中率 bufferpool-wait-free (InnoDB buffer pool waits for clean page available) Innodb的緩行沖池等待清理頁. log-waits (InnoDB log waits because of a too small log buffer) 因為太小log緩沖區(qū)導(dǎo)致inndob log等待
21、. 19 check_mysql_health tablecache-hitrate (Table cache hitrate) 表緩存命中率 table-lock-contention(Table lock contention) 連接鎖表率 table_locks_waited/table_locaks_immediate table_locak_waited:不能立即獲得的表的鎖表次數(shù) table_locak_immediate: 立即獲得的表的鎖表次數(shù). 小于1%較優(yōu),如果1%需要引起注意,3% 性能問題. index-usage (Usage of indices) 索引使用情況.
22、tmp-disk-tables (Percent of temp tables created on disk) 臨時表創(chuàng)建. slow-queries (Slow queries) 慢查詢 long-running-procs (long running processes) 長期運行的進程. cluster-ndbd-running (ndnd nodes are up and running) ndbd 集群節(jié)點運行狀況 sql (any sql command returning a single number) 執(zhí)行返回一個數(shù)字的任何SQL 。 告警值規(guī)則: 10 means Ale
23、rt, if 10 and 90: means Alert, if grant all privileges - on *.* - to identified by linuxtone;Query OK, 0 rows affected (0.00 sec)mysql flush privileges;Query OK, 0 rows affected (0.00 sec)OK - 2 client connection threads | threads_connected=2;10;2021 check_mysql_health三、示例:在監(jiān)控機上.#cd /usr/local/nagio
24、s/libexec/連接123查看數(shù)據(jù)庫查詢線程緩存命中率狀態(tài):# ./check_mysql_health -hostname 192.168.169.123 -port 3306 -username netseek -password linuxtone -mode threadcache-hitrateOK - thread cache hitrate 91.30% | thread_cache_hitrate=91.30%;90:;80: thread_cache_hitrate_now=91.30% connections_per_sec=0.0090: 表示小于90 warning
25、, 80 表示小于80 則critical查詢命中率# ./check_mysql_health -hostname 192.168.169.122 -port 3306 -username netseek -password linuxtone -mode qcache-hitrateWARNING - query cache hitrate 88.19% | qcache_hitrate=88.19%;90:;80: qcache_hitrate_now=78.57% selects_per_sec=0.7522 check_mysql_health三、示例:在監(jiān)控機上.調(diào)整告警閥值:#
26、./check_mysql_health -hostname 192.168.169.122 -port 3306 -username netseek -password linuxtone -w 80: -c 70: -mode qcache-hitrateOK - query cache hitrate 88.19% | qcache_hitrate=88.19%;80:;70: qcache_hitrate_now=85.63% selects_per_sec=0.52連接123數(shù)據(jù)庫查看鎖表率.# ./check_mysql_health -hostname 192.168.169.1
27、23 -port 3306 -username netseek -password linuxtone -mode table-lock-contentionOK - table lock contention 0.00% | tablelock_contention=0.00%;1;2 tablelock_contention_now=0.00%連接123數(shù)據(jù)庫查看數(shù)據(jù)庫服務(wù)器當前連接數(shù)量:# ./check_mysql_health -hostname 192.168.169.123 -port 3306 -username netseek -password linuxtone -mod
28、e threads-connectedOK - 2 client connection threads | threads_connected=2;10;2023 check_mysql_healthNagios相關(guān)配置# vi commands.cfg 添加如下:#check_health_mysqldefine command command_name check_mysql_health command_line $USER1$/check_mysql_health -hostname $ARG1$ -port $ARG2$ -username $ARG3$ -password $ARG4$ -mode $ARG5$ #vi sh-wt- 給上海網(wǎng)通兩臺DB服務(wù)器配置上mysql數(shù)據(jù)庫檢測: 在自己定的的配
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年春七年級語文下冊 第三單元 12 賣油翁說課稿 新人教版
- 12古詩三首《己亥雜詩》說課稿-2024-2025學(xué)年語文五年級上冊統(tǒng)編版
- 15 分享真快樂(說課稿)2023-2024學(xué)年統(tǒng)編版道德與法治 一年級下冊001
- 2025裝修工程泥工承包合同
- 7讓弦發(fā)出高低不同的聲音 說課稿-2024-2025學(xué)年科學(xué)四年級上冊教科版
- 2024-2025學(xué)年高中歷史 專題四 王安石變法 一 積貧積弱的北宋教學(xué)說課稿 人民版選修1
- 14 請幫我一下吧 第一課時 說課稿-2023-2024學(xué)年道德與法治一年級下冊統(tǒng)編版
- 6我們神圣的國土 第1課時(說課稿)-部編版道德與法治五年級上冊
- 2023八年級英語下冊 Module 1 Feelings and impressions Unit 2 I feel nervous when I speak Chinese第三課時說課稿 (新版)外研版
- 2024-2025學(xué)年新教材高中語文 第二單元 6.2 文氏外孫入村收麥說課稿(3)部編版必修上冊
- 科技論文圖表等規(guī)范表達
- 高考寫作指導(dǎo)議論文標準語段寫作課件32張
- 2021年普通高等學(xué)校招生全國英語統(tǒng)一考試模擬演練八省聯(lián)考解析
- 華能火力發(fā)電機組節(jié)能降耗技術(shù)導(dǎo)則(2023年版)
- 基礎(chǔ)知識3500個常用漢字附拼音
- 企業(yè)易制毒化學(xué)品管理培訓(xùn)
- JJF(紡織)072-2018紡織滾筒式烘干機校準規(guī)范
- 北京故宮作文600字
- 羊水栓塞的應(yīng)急預(yù)案演練腳本
- 物業(yè)保潔及餐飲服務(wù)項目方案
- (新版教材)粵教粵科版六年級下冊科學(xué)全冊課時練(同步練習(xí))
評論
0/150
提交評論