天天看點

mysql性能監控工具:mycheckpoint的使用方法

mycheckpoint 是針對mysql的一個性能監控、名額采集的python寫成的工具。

工作原理說明:

mycheckpoint是一段腳本,通過将其設定為crontab定時任務,每幾分鐘采集一次資料(受限于crontab隻能是分鐘為基本機關)存儲在自己的資料庫中,并可以将采集的資料進行統計,以web頁面的形式展現出來。

示例效果:

mysql性能監控工具:mycheckpoint的使用方法
mysql性能監控工具:mycheckpoint的使用方法

詳細請參見:http://code.openark.org/forge/mycheckpoint

使用步驟:

0. 下載下傳:

 wget https://mycheckpoint.googlecode.com/files/mycheckpoint-231.tar.gz

1. 為mycheckpoint建立資料庫 

CREATE DATABASE mycheckpoint;      

2. 授權給目前登入mysql的使用者

GRANT ALL PRIVILEGES ON mycheckpoint.* TO 'root'@'localhost' IDENTIFIED BY 'xxxx';      

3. 建立mycheckpoint需要的資料庫表。

mycheckpoint --host=127.0.0.1 --port=3306 --user=root --password=xxxx --socket=/mysql/tmp/mysql.sock --database=mycheckpoint      

進過這一個步驟之後,會在名為:mycheckpoint資料庫中,生成以下資料表。

+------------------------------------+
| Tables_in_mycheckpoint             |
+------------------------------------+
| alert                              |
| alert_condition                    |
| alert_condition_query_view         |
| alert_email_message_items_view     |
| alert_pending                      |
| alert_pending_html_view            |
| alert_pending_view                 |
| alert_view                         |
| charts_api                         |
| custom_query                       |
| custom_query_top_navigation_view   |
| custom_query_view                  |
| html_components                    |
| metadata                           |
| numbers                            |
| status_variables                   |
| status_variables_aggregated_day    |
| status_variables_aggregated_hour   |
| sv_custom_chart_day                |
| sv_custom_chart_flattened_day      |
| sv_custom_chart_flattened_hour     |
| sv_custom_chart_flattened_sample   |
| sv_custom_chart_hour               |
| sv_custom_chart_sample             |
| sv_custom_html                     |
| sv_custom_html_brief               |
| sv_day                             |
| sv_diff                            |
| sv_hour                            |
| sv_latest                          |
| sv_param_change                    |
| sv_parameter_change_union          |
| sv_report_24_7                     |
| sv_report_24_7_minmax              |
| sv_report_chart_24_7               |
| sv_report_chart_day                |
| sv_report_chart_day_labels         |
| sv_report_chart_day_timeseries     |
| sv_report_chart_hour               |
| sv_report_chart_hour_labels        |
| sv_report_chart_hour_timeseries    |
| sv_report_chart_sample             |
| sv_report_chart_sample_labels      |
| sv_report_chart_sample_timeseries  |
| sv_report_day                      |
| sv_report_day_recent               |
| sv_report_day_recent_minmax        |
| sv_report_hour                     |
| sv_report_hour_recent              |
| sv_report_hour_recent_minmax       |
| sv_report_html                     |
| sv_report_html_24_7                |
| sv_report_html_brief               |
| sv_report_human_day                |
| sv_report_human_hour               |
| sv_report_human_sample             |
| sv_report_sample                   |
| sv_report_sample_recent            |
| sv_report_sample_recent_aggregated |
| sv_report_sample_recent_minmax     |
| sv_sample                          |
+------------------------------------+      

如果意外将你的web app 的DB指定成了log資料庫,則會在你的web app DB中加入以上資料表,并将原web app DB中重名的資料表删除。這将是災難性的!

4. 将mycheckpoint配置成定時任務

* * * * * /usr/local/bin/mycheckpoint  --user=root --password=xxxx --socket=/redmine/mysql/tmp/mysql.sock --database=mycheckpoint      

5. http方式檢視結果:

mycheckpoint --host=127.0.0.1 --port=3306 --user=root --password=xxxx --socket=/mysql/tmp/mysql.sock --database=mycheckpoint  http      

指定資料庫時需注意,切莫使用你的web app 的DB. 

一個小時之後就可以打開本地的http://localhost:12306/mycheckpoint 檢視報表。

點評: 

這個工具的優勢是能将資料統計結果以web形式展現,但是由于其依賴crontab,導緻資料采集間隔過大,不能很好的描述mysql的運作狀況, 另外,此工具已經于2014年4月停止更新。

其它的mysql第三方工具還有: percona-toolkit / mysqltuner.pl / tuning-primer.sh 等。

參考:

1. http://code.openark.org/forge/mycheckpoint

2. https://code.google.com/p/mycheckpoint/downloads/list

作者:

fandyst

出處:

http://www.cnblogs.com/todototry/

關注語言:

python、javascript(node.js)、objective-C、java、R、C++

興趣點:

網際網路、大資料技術、大資料IO瓶頸、col-oriented DB、Key-Value DB、資料挖掘、模式識别、deep learning、開發與成本管理

産品:

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接。