標籤:
=============
歡迎轉載,請註明出處
李慧 (DBA)
日期:20151008
=============
1 安裝Percona Toolkit
去官網下載
2. 安裝Anemometer
:https://github.com/box/Anemometer
3.下載PHP 相關模組
yum -y install php*
主要看這些模組:
php-common-5.3.3-1.el5
php-bcmath-5.3.3-1.el5
php-mysql-5.3.3-1.el5
php-dba-5.3.3-1.el5
php-cli-5.3.3-1.el5
php-gd-5.3.3-1.el5
php-5.3.3-1.el5
php-pdo-5.3.3-1.el5
4.啟動apache服務
rpm -qa|grep http
httpd-2.2.3-45.el5
5..執行setup 指令碼,建立使用者:
[[email protected]/var/www/html/anemometer]mysql -uroot -pxxx < install.sql
[[email protected]/var/www/html/anemometer]mysql -uroot -pxxx
mysql > grant all on slow_query_log.* to ‘anemometer‘@‘%‘ identified by ‘123456‘;
mysql > grant all on slow_query_log.* to ‘anemometer‘@‘localhost‘ identified by ‘123456‘;
mysql > grant select on *.* to ‘anemometer‘@‘%‘;
mysql > grant all on slow_query_log.* to ‘anemometer‘@‘localhost‘;
mysql > grant select on *.* to ‘anemometer‘@‘localhost‘;
6.修改PHP設定檔:
vim /etc/php.ini
7.修改WEB頁面:
cd /var/www/html/anemometer/conf
cp sample.config.inc.php config.inc.php
vi config.inc.php
以及
8. 修改APACHE設定檔“
cat /etc/httpd/conf/httpd.conf |grep "ServerName" |grep -v ‘^#‘
ServerName 10.1.11.99:80
重啟HTTP,訪問不了,報錯如下:
tail -f /etc/httpd/logs/error_log
解決方案如下:
9:訪問頁面:
10.1.11.99/anemometer
11.匯入慢查詢日誌
pt-query-digest --user=anemometer --password=123456 --socket=/tmp/mysql3306.sock --review h=localhost,D=slow_query_log,t=global_query_review --history h=localhost,D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /opt/soft/slow_query_2015-09-24.log
參考:http://www.bubuko.com/infodetail-495427.html
https://github.com/box/Anemometer
http://blog.itpub.net/26355921/viewspace-1162415/
使用Anemometer基於pt-query-digest將MySQL慢查詢可視化