




免费预览已结束,剩余23页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MySQLMonitoring ChinaUnix网友技术交流曹金成NetSeekEmail cnseek 2009 3 28 MySQLMonitoring 一 如何有效监控 监控的目的二 基本监控解决方案 基础数据收集 三 高级解决方案 数据库健康状态 优化 四 MySQL性能相关交互式监控工具五 相关资源参考 一 如何有效监控 一 如何有效监控 监控的目的 1 服务健康监测 存活 故障告警 2 监控系统采集数据 依据数据进行调优 二 基本监控解决方案 二 基本监控解决方案 收集系统信息 top vmstat iostat mpstat mytop dstata free proc mstat mtop 命令行工具分析系统资源使用状况 三 高级监控解决方案 三 高级监控解决方案1 Nagios相关 收集数据库信息及健康状态 对数据库调整优化 check mysql 推荐 nagios mysql plugins 0 3 适当选择 check mysql health 重点介绍推荐 由于时间关系本PPT只重点介绍一下Nagios相关的插件脚本 重点介绍一下check mysql health监控数据库调优 2 MySQLActivityReport基于rrdtool http gert sos be en projects mysqlar http gert sos be demo mysqlar 演示网站 三 高级监控解决方案 三 高级监控解决方案 3 CACTI MySQL模板 Nagioscheck mysql cd usr local nagios libexec check mysql help 查看使用说明 Usage check mysql ddatabase Hhost Pport ssocket uuser ppassword S Options h helpPrintdetailedhelpscreen V versionPrintversioninformation H hostname ADDRESSHostname IPAddress orunixsocket mustbeanabsolutepath P port INTEGERPortnumber default 3306 s socket STRINGUsethespecifiedsocket hasnoeffectif Hisused d database STRINGCheckdatabasewithindicatedname u username STRINGConnectusingtheindicatedusername p password STRINGUsetheindicatedpasswordtoauthenticatetheconnection IMPORTANT THISFORMOFAUTHENTICATIONISNOTSECURE Yourclear textpasswordcouldbevisibleasaprocesstableentry S check slave 检测Slave状态 Checkiftheslavethreadisrunningproperly w warningExitwithWARNINGstatusifslaveserverismorethanINTEGERsecondsbehindmaster c criticalExitwithCRITICALstatusifslaveserverismorethenINTEGERsecondsbehindmaster Nagioscheck mysql 示例 Nagios监控服务器 192 168 169 138如要监控DB服务器192 168 169 204和SlaveDB服务器192 168 169 123数据库授权 登陆DB服务器 进行授权用户名netseek 密码linuxtone mysql grantallprivileges on tonetseek 192 168 169 138identifiedby linuxtone QueryOK 0rowsaffected 0 00sec mysql flushprivileges QueryOK 0rowsaffected 0 00sec Nagioscheck mysql 示例 在监控机上 cd usr local nagios libexec 连接204查看数据库状态 check mysql H192 168 169 204 unetseek plinuxtoneUptime 2146510Threads 1Questions 61155591Slowqueries 325Opens 1273Flushtables 1Opentables 767Queriespersecondavg 28 491连接数据库123查看 check mysql H192 168 169 123 unetseek plinuxtone S w60 c600Uptime 35349Threads 1Questions 4022Slowqueries 0Opens 38Flushtables 1Opentables 32Queriespersecondavg 0 114SlaveIO YesSlaveSQL YesSecondsBehindMaster 0OK 在命令行下都能正常连接数据库 Check mysqlNagios配置 vicommands cfg添加如下 check mysqldefinecommand command namecheck mysqlcommand line USER1 check mysql H ARG1 P ARG2 u ARG3 p ARG4 仔细看参数传递与上面的命令行对应 check slavedefinecommand command namecheck slavecommand line USER1 check mysql H ARG1 P ARG2 u ARG3 p ARG4 S w ARG5 c ARG6 Check mysqlNagios配置 vish wt www db cfg给上海网通两台DB服务器配置上mysql数据库检测 在自己定的的配置文件里 添加如下服务段 check mysqldefineservice host namedbss masterservice descriptioncheck mysqlcheck commandcheck mysql 192 168 169 122 3306 netseek linuxtone checkslavedefineservice host namedbss slaveservice descriptioncheck slavecheck commandcheck slave 192 168 169 123 3306 netseek linuxtone 60 600 Nagioscheck mysql check mysql监控演示效果Check mysql S模块可以很好的检测mysqlreplicationslave的健康状态 mysql showslavestauts G 是否工作Slave IO running YESSlave SQL running YES 延迟情况Sencodes behind master nagios mysql plugins 选择性的使用此插件来配合监控工作 wgethttp www shinguz ch MySQL nagios mysql plugins 0 3 tar gz tarzxvfnagios mysql plugins 0 3 tar gz cdnagios mysql plugins 0 3 chmoda x mv usr local nagios libexec插件解释 check db mysql pl检测mysql是否运行 check errorlog mysql pl检测数据库下的错误日志perf mysql pl收集性能数据 类似后面要讲的check mysql healthreplication相关 check repl mysql cnt slave hosts pl 检测复制相关 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 pl nagios mysql plugins check db mysql pl h192 168 169 204 unetseek plinuxtone port3306编写commanddefinecommand command namecheck db mysqlcommand line USER1 check db mysql pl h ARG1 u ARG2 p ARG3 port ARG4 服务端配置 check commandcheck db mysql 192 168 169 204 netseek linuxtone 3306 check mysql health 一 安装check mysql health官方网站 http www consol de opensource nagios check mysql health wgethttp www consol de fileadmin opensource Nagios check mysql health 2 0 3 tar gz tarzxvfcheck mysql health 2 0 3 tar gz cdcheck 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 makeinstall注 check mysql health check mysql perf的替代方案 官方不再支持check mysql perf 详细参见 check mysql health 二 check mysql health插件使用说明 cd usr local nagios libexec check mysql health helpCheckvariousparametersofMySQLdatabasesUsage check mysql health v t hostname port socket username password mode methodmysql check mysql health h help check mysql health V version check mysql health Options hostnamethedatabaseserver shostname portthedatabase sport default 3306 socketthedatabase sunixsocket usernamethemysqldbuser passwordthemysqldbuser spassword databasethedatabase sname default information schema warningthewarningrange criticalthecriticalrange check mysql health modethemodeoftheplugin selectoneofthefollowingkeywords connection time Timetoconnecttotheserver 连接到服务器的时间 uptime Timetheserverisrunning MySQL服务器运行的时间threads connected Numberofcurrentlyopenconnections 数据库服器当前打开的连接threadcache hitrate Hitrateofthethread cache 线程缓存命中率 mysqlreplication相关段 slave lag Secondsbehindmaster 判断slave落后于master多少秒slave io running Slaveiorunning Yes 表明Slave复制正常运行slave sql running Slavesqlrunning Yes 表明Slave复制正常运行用check mysql模块来替代这些功能更 check mysql是用C写的执行速度更快 check slave check mysql H192 168 169 123 unetseek plinuxtone S来解决 check mysql health 查询缓存相关 qcache hitrate Querycachehitrate 查询命中率 这个比率越高则表明服务器的SELECT查询性能就越好qcache lowmem prunes Querycacheentriesprunedbecauseoflowmemory 由于内存较小从缓存删除的查询数量增大query cache size的值 以减小lowmem 增加缓存命中率keycache hitrate MyISAMkeycachehitrate nkey缓存命中率如果命中率低 则调大key buffer size InnoDBCache命中率 bufferpool hitrate InnoDBbufferpoolhitrate Innodb缓冲池命中率bufferpool wait free InnoDBbufferpoolwaitsforcleanpageavailable Innodb的缓行冲池等待清理页 log waits InnoDBlogwaitsbecauseofatoosmalllogbuffer 因为太小log缓冲区导致inndoblog等待 check mysql health tablecache hitrate Tablecachehitrate 表缓存命中率table lock contention Tablelockcontention 连接锁表率table locks waited table locaks immediatetable locak waited 不能立即获得的表的锁表次数table locak immediate 立即获得的表的锁表次数 小于1 较优 如果1 需要引起注意 3 性能问题 index usage Usageofindices 索引使用情况 tmp disk tables Percentoftemptablescreatedondisk 临时表创建 slow queries Slowqueries 慢查询long running procs longrunningprocesses 长期运行的进程 cluster ndbd running ndndnodesareupandrunning ndbd集群节点运行状况sql anysqlcommandreturningasinglenumber 执行返回一个数字的任何SQL 告警值规则 10 means Alert if 10 and 90 means Alert if 90 check mysql health 三 示例 Nagios监控服务器 192 168 169 138如要监控DB服务器192 168 169 204和SlaveDB服务器192 168 169 123数据库授权 登陆DB服务器 进行授权用户名netseek 密码linuxtone mysql grantallprivileges on tonetseek 192 168 169 138identifiedby linuxtone QueryOK 0rowsaffected 0 00sec mysql flushprivileges QueryOK 0rowsaffected 0 00sec OK 2clientconnectionthreads threads connected 2 10 20 check mysql health 三 示例 在监控机上 cd usr local nagios libexec 连接123查看数据库查询线程缓存命中率状态 check mysql health hostname192 168 169 123 port3306 usernamenetseek passwordlinuxtone modethreadcache hitrateOK threadcachehitrate91 30 thread cache hitrate 91 30 90 80 thread cache hitrate now 91 30 connections per sec 0 0090 表示小于90warning 80表示小于80则critical查询命中率 check mysql health hostname192 168 169 122 port3306 usernamenetseek passwordlinuxtone modeqcache hitrateWARNING querycachehitrate88 19 qcache hitrate 88 19 90 80 qcache hitrate now 78 57 selects per sec 0 75 check mysql health 三 示例 在监控机上 调整告警阀值 check mysql health hostname192 168 169 122 port3306 usernamenetseek passwordlinuxtone w80 c70 modeqcache hitrateOK querycachehitrate88 19 qcache hitrate 88 19 80 70 qcache hitrate now 85 63 selects per sec 0 52连接123数据库查看锁表率 check mysql health hostname192 168 169 123 port3306 usernamenetseek passwordlinuxtone modetable lock contentionOK tablelockcontention0 00 tablelock contention 0 00 1 2tablelock contention now 0 00 连接123数据库查看数据库服务器当前连接数量 check mysql health hostname192 168 169 123 port3306 usernamenetseek passwordlinuxtone modethreads connectedOK 2clientconnectionthreads threads connected 2 10 20 check mysql health Nagios相关配置 vicommands cfg添加如下 check health m
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 房屋 公租 合同范本
- 广场饭店合同范本
- 重庆江津购房合同范本
- 民房混凝土施工合同范本
- 地豇豆订购合同范本
- 电源供应合同范本
- 就业协议合同范本简约
- 天下租房合同范本
- 舞蹈电子培训合同范本
- 足浴店监工合同范本
- 2025至2030中国超前和靶向药物输送行业发展趋势分析与未来投资战略咨询研究报告
- 2025江苏南京农业大学新校区建设指挥部、基本建设处人员招聘10人笔试备考试题及答案解析
- 信号与系统(第2版)课件 1.0 绪论
- VTE的预防及护理
- 护理伦理的概论
- ABS风口供货合同范本
- 2025年燃气经营企业从业人员专业考试历年参考题库含答案详解(5套)
- 2025年食品安全法试题带答案
- 植物生物技术概论
- 食品委托加工协议书范文6篇
- 中文版儿童睡眠习惯问卷CSHQ 含评分维度
评论
0/150
提交评论