If you're just completely itching to start using this tool, here's what you need:
1、a MySQL database to store query analysis data in.
2、pt-query-digest.You may as well just get the whole Percona Toolkit while you're at it :)
3、a slow query log from a MySQL server (see The Slow Query Log for info on getting one)
4、a webserver with PHP
Install anemometer
First up, grab the anemometer code from github. Navigate to the document root of your web server and snag a copy of the Box Anemometer code.
then change your current working directory to the anemometer directory:
1
[iyunv@xiaoya ~]# cd anemometer
Next, you should connect to the MySQL database you're looking to store the analysis data in and issue the following command:
1
2
3
[iyunv@xiaoya anemometer]# mysql -uroot -p123456 < install.sql
[iyunv@xiaoya anemometer]# mysql -uroot -p123456 -e "grant ALL ON slow_query_log.* to
BY '123456';"
Next, grab that slow query log file you have (mine's called "slow.log"!), and run pt-query-digest on it: NOTE: I'm using a BASH 3.0 shell here on my MySQL database server! This is so the "$HOSTNAME" variable properly replaces with "db.example.com")
You may see an error like above, that's okay! TODO: explain what the options above are doing.
1
2
3
4
5
Pipeline process 11 (aggregate fingerprint) caused an error: Argument "57A" isn't numeric in numeric gt (>) at (eval 40) line 6, <> line 27.
Pipeline process 11 (aggregate fingerprint) caused an error: Argument "57B" isn't numeric in numeric gt (>) at (eval 40) line 6, <> line 28.
Pipeline process 11 (aggregate fingerprint) caused an error: Argument "57C" isn't numeric in numeric gt (>) at (eval 40) line 6, <> line 29.
View the data!Now, navigate to the document root of your web server and copy the sample config so you can edit it:
1
2
[iyunv@xiaoya conf]# cd /home/wwwroot/anemometer/conf
[iyunv@xiaoya conf]# cp sample.config.inc.php config.inc.php
The sample config explains every setting you may want to change in it. At the very least, make sure you set the Datasource to the MySQL database you're storing the analyzed digest information in:
In addition, the "explain" plugin is enabled by default in the current release and you'll need to setup the username and password it uses to an account that has privileges to explain queries on a given schema on a host. For example, if you're digesting slow logs that primarily contain queries from the "world" database on db.example.com, you'll need to ensure that the user account you put into the following section of the config has the necessary privileges on the "world" database on db.example.com. To do this, scroll down in the sample config to the section containing the plugins configuration and change the 'user' and 'password' parameters to an appropriate account: