如何监控MYSQL的性能

How to Monitor MySQL's performance
Here are some ideas, how you can monitor the database performance of your MySQL installation. Monitoring is always an iterative and continuous process. You need to learn what patterns are OK for your database and what are the signs of slight problems or even dangerous situations.

Below are the main items you can use to monitor your system:
- mysqladmin extended (absolute values)
- mysqladmin extended -i10 -r (relative values)
- mysqladmin processlist
- mysql -e "show innodb status"
- OS data. vmstat/iostat
- MySQL error log
- InnoDB tablespace info.

1) mysqladmin extended (absolute values)

The values making most sense to monitor are:
* Slave_running: If the system is a slave replication server, this is an indication of the slave's health.
* Threads_connected: The number of clients currrently connected. This should be less than some preset value (like 200), but you can also monitor that it is larger than some value to ensure that clients are active.
* Threads_running: If the database is overloaded you'll get an increased number of queries running. That also should be less than some preset value (20?). It is OK to have values over the limit for very short times. Then you can monitor some other values, when the Threads_running was more than the preset value and when it did not fall back in 5 seconds.

2) mysqladmin extended (counters)
The idea is that you store the performance counter value and compute the difference with the new values. The interval between the recordings should be more than 10 seconds. The following values are good candidates for checking:

* Aborted_clients: The number of clients that were aborted (because they did not properly close the connection to the MySQL server). For some applications this can be OK, but for some other applications you might want to track the value, as aborted connects may indicate some sort of application failure.
* Questions: Number of queries you get per second. Also, it's total queries, not number per second. To get number per second, you must divide Questions by Uptime.
* Handler_*: If you want to monitor low-level database load, these are good values to track. If the value of Handler_read_rnd_next is abnormal relative to the value that you normally would expect, it may indicate some optimization or index problems. Handler_rollback will show the number of queries that have been rolled back. You might want to wish to investigate them.
* Opened_tables: Number of table cache misses. If the value is large, you probably need to increase table_cache. Typically you would want this to be less than 1 or 2 opened tables per second.
* Select_full_join: Joins performed without keys. This should be zero. This is a good way to catch development errors, as just a few such queries can degrease the system's performance.
* Select_scan: Number of queries that performed a full table scan. In some cases these are OK but their ratio to all queries should be constant. if you have the value growing it can be a problem with the optimizer, lack of indexes or some other problem
* Slow_queries: Number of queries longer than --long-query-time or that are not using indexes. These should be a small fraction of all queries. If it grows, the system will have performance problems.
* Threads_created: This should be low. Higher values may mean that you need to increase the value of thread_cache or you have the amount of connections increasing, which also indicates a potential problem.

3) mysqladmin processlist or "SHOW FULL PROCESSLIST" command
You can get the number of threads connected and running by using other statistics, but this is a good way to check how long queries that are running take. If there are some very long-running queries (e.g. due to being badly formulated) the admin should be informed. You might also want to check how many queries are in "Locked" state - these are not counted as running but are inactive, i.e. a user is waiting on the database to respond.

4) "SHOW INNODB STATUS"
This statement produces a great deal of information, from which you should extract the parts in which you are interested. The first thing you need to check is: "Per second averages calculated from the last xx seconds". InnoDB rounds stats each minute.

* Pending normal aio reads: These are InnoDB IO request queue sizes. If they are bigger than 10-20 you might have some bottleneck.
* reads/s, avg bytes/read, writes/s, fsyncs/s: These are IO statistics. Large values for reads/writes means the IO subsystem is being loaded. Proper values for these depend on your system configuration.
* Buffer pool hit rate: The hit rate also depends a lot on your application. Check your hit rate, when there are problems.
* inserts/s, updates/s, deletes/s, reads/s: These are low level row operations that InnoDB does. You might use these to check your load if it is in expected range.

4) OS Data. Good tools to see the system status are vmstat/iostat/mpstat.

To see what kind of information these tools can provide for you,
read their man pages.

5) MySQL error log - Nothing should written to the error log, after the server has completed its initialization sequence, so everything appearing in the log should be brought to admin's attention immediately.

6) InnoDB tablespace info.
With InnoDB the only danger is that the tablespace gets full - the logs can't get full. Best way to check this is to do: show table status;

You can use any InnoDB table for monitoring the InnoDB table space free space.

平均得分
(0 次评分)





文章来自: 本站原创
标签: 性能 mysql 监控 
评论: 10 | 查看次数: 3855
  • 共有 10 条评论
beeflee [2009-05-05 17:45:00]
游客 [2009-01-14 22:45:03]
游客 [2009-01-08 13:33:34]
セックスフレンド無料サイト-プレミアム出会い放題メル友を探そう不倫人妻秘密サークル出会い系サーチ出会い-Lovers出会い探しセックスフレンド大陸スタビLuxury人妻Magic!!ご近所の人妻探し出会い系案内所出会い系オンリー人妻がハマる出会い系出会い系サイトFreedom女子高生メル友ちぇき!セフレ伝説セフレPlaySpotご近所のアイシテル!メル友無料募集サイト素敵な恋人探しセフレステーション出会い探し不倫ありませんか!プチ家出掲示板NO.1!リターンズご近所のメル友探し出会いの森素敵なメル友探し人妻DXピンクの恋人
游客 [2008-12-30 15:02:23]
术+术:可能是唯一有可能冲上2300的同职业组合,天赋一般选用双恶魔法+贼:控制+爆发型,法师的爆发力略胜术士,不过容错性非常小,游戏相似组合还有法+野D,法+暗牧法+法:双冰法控制,综合来说还不错,续战力也存活能力也很强。双奥法的秒杀流一经提出就被喷的面目全非,我本人其实尝试过这个组合,可惜装备只有S2,法伤最多也只能撑到102X(现在能高不少),魔兽队友情况也差不多。这样的组合容错性低的离谱,虽然有10000+HP 400+韧性,但是感觉一被打就瞬间死,而且跑还跑不掉,所以这个打法还是更适合高端副本装,反正一样死很快。组合上还是克死战士队,别和我提盾反,网络游戏那么明显的动画效果能吸到个火冲不错了。网游基本上能够硬顶过我们5秒的职业只有骑士,冰法,盗贼和恶魔SS了。打盗贼队伍,如果是盗贼+看的见,一律先把看的见的OOXX了,双盗贼很难打,2斗篷我们免费网络游戏直接去一人。最后被一个队恶魔SS+骑士卡住了,因为奥法的后续爆发几乎没有,开局秒恶魔SS和骑士都不成功。感觉装备足够猛的话,2000是没问题的,2000以后看能否连好沉默来秒SS了。法伤最好是NOBUFF 1200+以上,最新网游保证秒杀的成功率,可以不用考虑血和韧性,建议装备牛B的法师们平时娱乐使用,非常畅快的战斗贼+暗牧:爆发力非常强的组合,而且他们的视频里很不厚道的最新免费网络游戏吃了金童3场贼+野D:第一赛季闷+盲+消失补闷+飓风的完美控制秒杀型队伍,不过在徽章能解所有控制技能之后容错性大大降低了。
游客 [2008-12-02 15:12:15]
游客 [2008-11-29 16:12:17]
游客 [2008-10-16 13:59:12]
游客 [2008-09-28 12:57:39]
游客 [2008-09-24 18:27:48]
If you have played World . mp3playershopping.de/Shops/8GB-MP3-Player.aspx]8GB MP3 PLAYER[/url] of Warcraft for any amount of time. you will be able to relate to what I'm about to share with you. apple ipodFor the first time ever. buy cheap wow gold my self-used secrets of the power of leveling. which I have used to. canon digital camera count the ones I helped with. cheap world of warcraft gold friends. WARNING This. digital cameraof the way I learned how to level.digital cameras I wanted in World of Warcraft. dvd player Not only that. eve isk leveling speed to. below 6 days /played! We are only . ipod at the beginning of this letter. ipod nano If I were you.ipod shuffle And you are completely right to.ipod touch Look, if I wasn't the guy who used.ipods and seen the process with my own two eyes. mp3 player So let me set the record straight by pulling back . mp3 players mp4 I know you've heard people talk about ""competitive gamers"" before, you know. portable dvd players no life, and they Eat. Sleep and Breath gaming. world of warcraft buy gold So right now. wow I'm going to set the records straight and let you . wow gold I started playing. wow gold Completely blind to any concept of the game. wow leveling This is before The Burning Crusade. wow powerleveling Unfortunately I made that character before I found out. zubehoer mp3 player They talked me into switching servers and playing with them.
游客 [2008-09-24 18:27:38]
2GB MP3 PLAYER "In addition to providing . 4GB MP3 PLAYER my own WoW Leveling Guide to help you maximize your. buy wow gold WoW enjoyment I’ll discuss . buying gold world of warcraft other great WoW leveling guides available to you along with. cell phones the problems and benefits of power leveling . cheap cell phones guides and power leveling services. cheap wow gold I may also poke a little fun at the . cheap wow gold WoW forum communities. cheap wow gold for their uncanny persistence . cheapest wow gold so you’ll eventually find both a horde .eve isk One important note about my approach . mp3 players I strictly avoid and discourage cheats and hacks. phones cell and I also strongly discourage paying for leveling services. portable mp3 player This game is meant to be played; it is meant to be FUN. portable mp3 players your money or making yourself feel lame for cheating. sell wow gold Joana’s Horde Leveling Guide and Brian Kopp’s Alliance Leveling Guide. world of warcraft gold give you some extra tips to help you maximize their usage. wow value than any power leveling service or cheat. wow gold you can use them over-and-over for the rest of your life. wow gold And they don’t teach methods that will either get you banned or make you feel lame. wow gold that one might argue you’re already at a disadvantage for not yet using them. wow gold it so boring and tedious that it ruined the game for you. wow gold This is what I want to avoid. wow gold I do encourage some aggressive and creative methods because . wow gold kaufen
help you learn methods you could already learn from .wow gold kaufen
  • 共有 10 条评论
发表评论
昵 称:  登录
内 容:
选 项:
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启