




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、 MySQL Monitoring 一、如何有效監(jiān)控如何有效監(jiān)控?監(jiān)控的目的監(jiān)控的目的 二、基本監(jiān)控解決方案基本監(jiān)控解決方案(基礎(chǔ)數(shù)據(jù)收集基礎(chǔ)數(shù)據(jù)收集) 三、高級(jí)解決方案高級(jí)解決方案(數(shù)據(jù)庫健康狀態(tài),優(yōu)化數(shù)據(jù)庫健康狀態(tài),優(yōu)化) 四、MySQL性能相關(guān)交互式監(jiān)控工具性能相關(guān)交互式監(jiān)控工具 五、相關(guān)資源參考相關(guān)資源參考 MySQL Monitoring一、如何有效監(jiān)控一、如何有效監(jiān)控?監(jiān)控的目的監(jiān)控的目的? 1 、服務(wù)健康監(jiān)測(cè)(存活,故障告警.) 2 、監(jiān)控系統(tǒng)采集數(shù)據(jù),依據(jù)數(shù)據(jù)進(jìn)行調(diào)優(yōu) 一 、如何有效監(jiān)控?二、基本監(jiān)控解決方案(收集系統(tǒng)信息) top 、vmstat 、iostat 、mpsta
2、t 、mytop 、dstata 、free 、/proc/. 、mstat 、mtop .命令行工具分析系統(tǒng)資源使用狀況. 二、 基本監(jiān)控解決方案 三、高級(jí)監(jiān)控解決方案三、高級(jí)監(jiān)控解決方案 1、Nagios相關(guān)相關(guān):(收集數(shù)據(jù)庫信息及健康狀態(tài),對(duì)數(shù)據(jù)庫調(diào)整優(yōu)化收集數(shù)據(jù)庫信息及健康狀態(tài),對(duì)數(shù)據(jù)庫調(diào)整優(yōu)化) check_mysql 推薦 nagios-mysql-plugins-0.3 適當(dāng)選擇 check_mysql_health 重點(diǎn)介紹推薦重點(diǎn)介紹推薦 由于時(shí)間關(guān)系本由于時(shí)間關(guān)系本PPT只重點(diǎn)介紹一下只重點(diǎn)介紹一下Nagios相關(guān)的插件腳本相關(guān)的插件腳本. 重點(diǎn)介紹一下重點(diǎn)介紹一下chec
3、k_mysql_health監(jiān)控?cái)?shù)據(jù)庫調(diào)優(yōu)。監(jiān)控?cái)?shù)據(jù)庫調(diào)優(yōu)。 2、MySQL Activity Report 基于rrdtool *http:/gert.sos.be/en/projects/mysqlar/ *http:/gert.sos.be/demo/mysqlar/ 演示網(wǎng)站 三、高級(jí)監(jiān)控解決方案 三、高級(jí)監(jiān)控解決方案三、高級(jí)監(jiān)控解決方案 3、CACTI * MySQL模板:http:/ 4、RRD 參考資料: * http:/vvv.k6p.de/rrd/ * http:/oss.oetiker.ch/rrdtool/rrdworld/ * http:/www.fi.muni.cz/
4、kas/mrtg-rrd/ * /internet/manage/rrdutil/faq/mysql.shtml 5、Munin * jects.linpro.no/ . 三、高級(jí)監(jiān)控解決方案 #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
5、detailed help screen -V, -version Print version information -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 databa
6、se with indicated name -u, -username=STRING Connect using 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 netseek38 identified by linuxtone; Q
7、uery OK, 0 rows affected (0.00 sec) mysql flush privileges; Query OK, 0 rows affected (0.00 sec) Nagios check_mysql 示例:示例:在監(jiān)控機(jī)上在監(jiān)控機(jī)上.#cd /usr/local/nagios/libexec/連接連接204查看數(shù)據(jù)庫狀態(tài)查看數(shù)據(jù)庫狀態(tài):#./check_mysql -H 04 -u netseek -p linuxtoneUptime: 2146510 Threads: 1 Questions: 61155591 Slow querie
8、s: 325 Opens: 1273 Flush tables: 1 Open tables: 767 Queries per second avg: 28.491連接數(shù)據(jù)庫連接數(shù)據(jù)庫123查看查看./check_mysql -H 23 -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
9、Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0OK,在命令行下都能正常連接數(shù)據(jù)庫: Nagios check_mysql# vi commands.cfg 添加如下:添加如下:#check_mysqldefine command command_name check_mysql command_line $USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ /仔細(xì)看參數(shù)傳遞與上面的命令行對(duì)應(yīng)仔細(xì)看參數(shù)傳遞與上面的命令行對(duì)應(yīng). #check_slavedefine com
10、mand command_name check_slave command_line $USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -S -w $ARG5$ -c $ARG6$ Check_mysql Nagios配置#vi sh-wt-www-db.cfg 給上海網(wǎng)通兩臺(tái)給上海網(wǎng)通兩臺(tái)DB服務(wù)器配置上服務(wù)器配置上mysql數(shù)據(jù)庫檢測(cè)數(shù)據(jù)庫檢測(cè):. 在自己定的的配置文件里,添加如下服務(wù)段.#check_mysqldefine service host_name dbss-master service_descriptio
11、n check_mysql check_command check_mysql!22!3306!netseek!linuxtone . #check slavedefine service host_name dbss-slave service_description check_slave check_command check_slave!23!3306!netseek!linuxtone!60!600 . Check_mysql Nagios配置 check_mysql監(jiān)控演示效果 Check_mysql S 模塊可以很好的檢測(cè)模塊可
12、以很好的檢測(cè)mysql replication slave的健康狀態(tài)的健康狀態(tài).mysqlshow slave stautsG *是否工作是否工作 Slave_IO_running: YES Slave_SQL_running: YES *延遲情況延遲情況 Sencodes_behind_master Nagios check_mysql選擇性的使用此插件來配合監(jiān)控工作選擇性的使用此插件來配合監(jiān)控工作# wget http:/www.shinguz.ch/MySQL/nagios-mysql-plugins-0.3.tar.gz# tar zxvf nagios-mysql-plugins-0
13、.3.tar.gz# cd nagios-mysql-plugins-0.3# chmod a+x *# mv * /usr/local/nagios/libexec插件解釋:check_db_mysql.pl 檢測(cè)mysql是否運(yùn)行.check_errorlog_mysql.pl 檢測(cè)數(shù)據(jù)庫下的錯(cuò)誤日志perf_mysql.pl 收集性能數(shù)據(jù),類似后面要講的check_mysql_healthreplication相關(guān).check_repl_mysql_cnt_slave_hosts.pl /檢測(cè)復(fù)制相關(guān)。check_repl_mysql_hearbeat.plcheck_repl_mysq
14、l_io_thread.plcheck_repl_mysql_read_exec_pos.plcheck_repl_mysql_readonly.plcheck_repl_mysql_seconds_behind_master.plcheck_repl_mysql_sql_thread.pl- nagios-mysql-plugins./check_db_mysql.pl -h 04 -u netseek -p linuxtone -port 3306編寫command define command command_name check_db_mysql comman
15、d_line $USER1$/check_db_mysql.pl -h $ARG1$ -u $ARG2$ -p $ARG3$ -port $ARG4$ . 服務(wù)端配置: . check_command check_db_mysql!04!netseek!linuxtone!3306 . nagios-mysql-plugins 一、安裝一、安裝check_mysql_health 官方網(wǎng)站:http:/www.consol.de/opensource/nagios/check-mysql-health/ # wget http:/www.consol.de/filea
16、dmin/opensource/Nagios/check_mysql_health-2.0.3.tar.gz # tar zxvf check_mysql_health-2.0.3.tar.gz # cd check_mysql_health-2.0.3 # ./configure -prefix=/usr/local/nagios -with-nagios-user=nagios - with-nagios-group=nagios -with-perl -with-statefiles-dir=/tmp # make & make install 注注:check_mysql_he
17、alth (check_mysql_perf的替代方案,官方不再支持的替代方案,官方不再支持 check_mysql_perf) 詳細(xì)參見:http:/ check_mysql_health二、二、check_mysql_health 插件使用說明插件使用說明 # cd /usr/local/nagios/libexec/ # ./check_mysql_health -help Check various parameters of MySQL databases Usage: check_mysql_health -v -t -hostname -port | -socket -usern
18、ame -password -mode -method mysql check_mysql_health -h | -help check_mysql_health -V | -version check_mysql_health . Options: -hostname 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
19、 password -database the databases name. (default: information_schema) -warning the warning range -critical the critical range check_mysql_health .-mode the mode of the plugin. select one of the following keywords: connection-time (Time to connect to the server) 連接到服務(wù)器的時(shí)間連接到服務(wù)器的時(shí)間. uptime (Time the s
20、erver is running) MySQL服務(wù)器運(yùn)行的時(shí)間服務(wù)器運(yùn)行的時(shí)間 threads-connected (Number of currently open connections) 數(shù)據(jù)庫服器當(dāng)前打開的連接數(shù)據(jù)庫服器當(dāng)前打開的連接 threadcache-hitrate (Hit rate of the thread-cache) 線程緩存命中率線程緩存命中率 -mysql replication 相關(guān)段相關(guān)段- slave-lag (Seconds behind master) 判斷判斷slave落后于落后于master多少秒多少秒 slave-io-running (Slave
21、 io running: Yes) 表明表明Slave復(fù)制正常運(yùn)行復(fù)制正常運(yùn)行 slave-sql-running (Slave sql running: Yes) 表明表明Slave復(fù)制正常運(yùn)行復(fù)制正常運(yùn)行 用用check_mysql 模塊來替代這些功能更模塊來替代這些功能更,check_mysql是用是用C寫的執(zhí)行速度更快寫的執(zhí)行速度更快. -check-slave ./check_mysql -H 23 -u netseek -p linuxtone -S 來解決來解決 check_mysql_health. -查詢緩存相關(guān)查詢緩存相關(guān)- qcache-hitr
22、ate (Query cache hitrate) 查詢命中率查詢命中率,這個(gè)比率越高則表明服務(wù)器的這個(gè)比率越高則表明服務(wù)器的SELECT 查詢性能就越好查詢性能就越好 qcache-lowmem-prunes (Query cache entries pruned because of low memory) 由于內(nèi)存較小從緩存刪除的查詢數(shù)量由于內(nèi)存較小從緩存刪除的查詢數(shù)量 增大增大query_cache_size的值,以減小的值,以減小lowmem,增加緩存命中率增加緩存命中率 keycache-hitrate (MyISAM key cache hitrate)n key緩存命中率緩存命
23、中率 如果命中率低,則調(diào)大如果命中率低,則調(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) 因?yàn)樘∫驗(yàn)樘?/p>
24、log緩沖區(qū)導(dǎo)致緩沖區(qū)導(dǎo)致inndob log等待等待. - check_mysql_health - tablecache-hitrate (Table cache hitrate) 表緩存命中率表緩存命中率 table-lock-contention(Table lock contention) 連接鎖表率連接鎖表率 table_locks_waited/table_locaks_immediate table_locak_waited:不能立即獲得的表的鎖表次數(shù)不能立即獲得的表的鎖表次數(shù) table_locak_immediate: 立即獲得的表的鎖表次數(shù)立即獲得的表的鎖表次數(shù). 小于小
25、于1%較優(yōu),如果較優(yōu),如果1%需要引起注意,需要引起注意,3% 性能問題性能問題. index-usage (Usage of indices) 索引使用情況索引使用情況. tmp-disk-tables (Percent of temp tables created on disk) 臨時(shí)表創(chuàng)建臨時(shí)表創(chuàng)建. slow-queries (Slow queries) 慢查詢慢查詢 long-running-procs (long running processes) 長(zhǎng)期運(yùn)行的進(jìn)程長(zhǎng)期運(yùn)行的進(jìn)程. cluster-ndbd-running (ndnd nodes are up and runni
26、ng) ndbd 集群節(jié)點(diǎn)運(yùn)行狀況集群節(jié)點(diǎn)運(yùn)行狀況 sql (any sql command returning a single number) 執(zhí)行返回一個(gè)數(shù)字的任何執(zhí)行返回一個(gè)數(shù)字的任何SQL 。 告警值規(guī)則告警值規(guī)則: 10 means Alert, if 10 and 90: means Alert, if grant all privileges - on *.* - to netseek38 identified by linuxtone;Query OK, 0 rows affected (0.00 sec)mysql flush privileges
27、;Query OK, 0 rows affected (0.00 sec)OK - 2 client connection threads | threads_connected=2;10;20 check_mysql_health三、示例:三、示例:在監(jiān)控機(jī)上在監(jiān)控機(jī)上.#cd /usr/local/nagios/libexec/連接連接123查看數(shù)據(jù)庫查詢線程緩存命中率狀態(tài)查看數(shù)據(jù)庫查詢線程緩存命中率狀態(tài):# ./check_mysql_health -hostname 23 -port 3306 -username netseek -password linux
28、tone -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, 80 表示小于表示小于80 則則critical查詢命中率查詢命中率# ./check_mysql_health -hostname 22 -port 3306 -username netseek -passwo
29、rd linuxtone -mode qcache-hitrateWARNING - query cache hitrate 88.19% | qcache_hitrate=88.19%;90:;80: qcache_hitrate_now=78.57% selects_per_sec=0.75 check_mysql_health三、示例:三、示例:在監(jiān)控機(jī)上在監(jiān)控機(jī)上.調(diào)整告警調(diào)整告警閥閥值值:# ./check_mysql_health -hostname 22 -port 3306 -username netseek -password linuxtone -
30、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ù)庫查看鎖表率數(shù)據(jù)庫查看鎖表率.# ./check_mysql_health -hostname 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ù)器當(dāng)前連接數(shù)量數(shù)據(jù)庫查看數(shù)據(jù)庫服務(wù)器當(dāng)前連接數(shù)量:# ./check_mysql_health -hostname 23 -port 3306 -us
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 防腐木門施工方案
- 給水pe管施工方案
- 城市外墻修補(bǔ)施工方案
- 碎石樁施工方案
- 2024-2025學(xué)年高二生物人教版選擇性必修3教學(xué)課件 第3章 第2節(jié) 第1課時(shí) 目的基因的篩選與獲取、基因表達(dá)載體的構(gòu)建
- 美術(shù)培訓(xùn)機(jī)構(gòu)復(fù)學(xué)計(jì)劃
- 霸州防水施工方案電話
- 醫(yī)技個(gè)人工作總結(jié)
- 汽車零部件安全認(rèn)證
- 課題開題報(bào)告:核心素養(yǎng)導(dǎo)向的小學(xué)語文課程育人研究與省域?qū)嵺`
- 2025年遼寧現(xiàn)代服務(wù)職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫(含答案)
- 2025年服裝制版師(中級(jí))職業(yè)技能鑒定考試題(附答案)
- 高考模擬作文“中國游”“city不city”導(dǎo)寫及范文
- 福建省福州市2024-2025學(xué)年九年級(jí)上學(xué)期期末語文試題(解析版)
- 一年級(jí)下冊(cè)綜合實(shí)踐活動(dòng)教案2
- 九年級(jí)主題班會(huì)課件:遇見最好的自己(開學(xué)第一課)
- 2025版股權(quán)投資基金股份收購與退出機(jī)制協(xié)議3篇
- 【營銷方案】2025小紅書平臺(tái)營銷通案
- 2025年江西電力職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測(cè)試近5年??及鎱⒖碱}庫含答案解析
- 2025年棗莊科技職業(yè)學(xué)院高職單招語文2018-2024歷年參考題庫頻考點(diǎn)含答案解析
- 2025年吉安職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測(cè)試近5年??及鎱⒖碱}庫含答案解析
評(píng)論
0/150
提交評(píng)論