mycheckpoint 是针对mysql的一个性能监控、指标采集的python写成的工具。html
工做原理说明:python
mycheckpoint是一段脚本,经过将其设置为crontab定时任务,每几分钟采集一次数据(受限于crontab只能是分钟为基本单位)存储在本身的数据库中,并能够将采集的数据进行统计,以web页面的形式展示出来。mysql
示例效果:web
详细请参见:http://code.openark.org/forge/mycheckpointsql
使用步骤:数据库
0. 下载:api
wget https://mycheckpoint.googlecode.com/files/mycheckpoint-231.tar.gzapp
1. 为mycheckpoint建立数据库 socket
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