使用Anemometer基於pt-query-digest將MySQL慢查詢可視化

來源:互聯網
上載者:User

標籤:

=============

歡迎轉載,請註明出處

李慧 (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慢查詢可視化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.