Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Anemometer in Mysql

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to use Anemometer in Mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Preparation conditions:

1.MySQL enables slow query

two。 Install Percona Toolkit

Rpm-qa | grep percona

Percona-toolkit-2.2.7-1

3. Download Anemometer

Official website: https://github.com/box/Anemometer

4. Prepare php related modules (or yum)

5. Start the apache service

Rpm-qa | grep http

Httpd-2.2.3-45.el5

Installation:

1. Install Percona Toolkit:

Rpm-ivh percona-toolkit-2.2.7-1.noarch.rpm

two。 Extract the Anemometer package, rename it to anemometer, and move it to / var/www/html (apache default path)

Pwd

/ var/www/html/anemometer

3. Install php related modules:

Rpm-qa | grep php

Php53-common-5.3.3-1.el5

Php53-bcmath-5.3.3-1.el5

Php53-mysql-5.3.3-1.el5

Php53-dba-5.3.3-1.el5

Php53-cli-5.3.3-1.el5

Php53-gd-5.3.3-1.el5

Php53-5.3.3-1.el5

Php53-pdo-5.3.3-1.el5

NOTE:

The PHP version should be greater than 5.3, otherwise an error will be reported, such as:

Anemometer requires PHP 5.3 or newer. You have 5.1.6

In addition, bcmath is required.

Rpm-qa | grep bcmath

Php53-bcmath-5.3.3-1.el5

4. Execute the setup script to create the user:

Mysql-uroot-pxxx

< install.sql [root@/var/www/html/anemometer]mysql -uroot -pxxx mysql >

Grant all on slow_query_log.* to 'anemometer'@'%' identified by' test'

Mysql > grant select on *. * to 'anemometer'@'%'

Mysql > grant all on slow_query_log.* to 'anemometer'@'localhost'

Mysql > grant select on *. * to 'anemometer'@'localhost'

5. After pt-query-digest analysis, the slow query log is stored in the database:

Statements with pt version less than 2.2:

Pt-query-digest-user=anemometer-password=test\

-- review hobb.example.com.During records queryreviewing logrecoveryglobalquestions queryreview\

-- review-history hobb.example.com.During records queryrecording logrecoveryglobaldatabases queryrecording walled history\

-- no-report-- limit=0%\

-- filter= "\ $event- > {Bytes} = length (\ $event- > {arg}) and\ $event- > {hostname} =\" $HOSTNAME\ ""\

/ root/test/localhost-slow.log

Statements with pt version greater than version 2.2:

Pt-query-digest-- user=anemometer-- password=test-- review h=hd-119-186There is a review of the whole globalcalendar queryreview-- history h=hd-119-186data queryreview-- history h=hd-119-186Doblesqueryreview-- no-report-- limit=0%-- filter= "\ $event- > {Bytes} = length (\ $event- > {arg}) and\ $event- > {hostname} =\ $HOSTNAME\" / root/test/localhost-slow.log

After performing this operation, the slow log will be analyzed and stored in mysql's slow_query_log database.

NOTE:

Remember to ensure the access to the corresponding 'user' @ 'host'

6. Modify the configuration information of the visual interface:

Cd / var/www/html/anemometer/conf

Cp sample.config.inc.php config.inc.php

Vi config.inc.php

And:

NOTE:

The hostname must be modified correctly and cannot be left as localhost, otherwise the final interface will be inaccessible.

7. Finally, local access through IP:

Http://192.168.44.130/anemometer

After query, you can get the results of the slow query log:

Supplement: how to monitor multiple databases

[root@RZ-SI1-DB-14 conf] # ll

Total 40

-rwxr-xr-x 1 root root 15504 Oct 12 14:51 config.inc.php # the new version does not need to modify the configuration, just the following datasource

-rwxrwxrwx 1 root root 314 Oct 12 14:54 datasource_si1.inc.php

-rwxr-xr-x 1 root root 314 Oct 12 15:05 datasource_st1.inc.php-configure multiple datasource,si1 st1 machines to import install.sql and pt-query-digest slow logs respectively

-rwxrwxrwx 1 root root 0 Oct 13 2016 index.html

-rwxrwxrwx 1 root root 15487 Oct 13 2016 sample.config.inc.php

[root@RZ-SI1-DB-14 conf] # more datasource_si1.inc.php

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report