In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to use Anemometer to analyze MySQL slow query records. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
Database administrators generally use percona's toolkit tool to analyze MySQL slow query records, but it is not intuitive enough.
Here is a more intuitive tool to statistically analyze MySQL slow query records anemometer.
Percona's toolkit needs to be installed before use, and anemometer provides a web interface.
1. Toolkit installation
# cd /data/www/my.xuebuyuan.com
# git clone https://github.com/box/Anemometer.git anemometer
# cd anemometer
2. Create tables and user names
mysql
< install.sql mysql -e "grant ALL ON slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY 'my.xuebuyuan.com';" mysql -e "grant SELECT ON *.* to 'anemometer'@'localhost' IDENTIFIED BY 'my.xuebuyuan.com';" 3. 分析MySQL慢日志 # pt-query-digest --user=anemometer --password=superSecurePass \ --review D=slow_query_log,t=global_query_review \ --review-history D=slow_query_log,t=global_query_review_history \ --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /data/log/mysql/slow.log
4. Configure anemometer
# cp conf/sample.config.inc.php conf/config.inc.php
# vi conf/config.inc.php
$conf['datasources']['localhost'] = array(
'host' => 'localhost',
'port' => 3306,
'db' => 'slow_query_log',
'user' => 'anemometer',
'password' => 'my.ttlsa.com',
'tables' => array(
'global_query_review' => 'fact',
'global_query_review_history' => 'dimension'
),
'source_type' => 'slow_query_log'
);
$conf['plugins'] = array(
'visual_explain' => '/usr/bin/pt-visual-explain',
'query_advisor' => '/usr/bin/pt-query-advisor',
#... other lines
$conn['user'] = 'anemometer';
$conn['password'] = 'my.ttlsa.com';
return $conn;
},
5. automated processing
# vi /etc/logrotate.d/mysql
postrotate
pt-query-digest --user=anemometer --password=superSecurePass \
--review D=slow_query_log,t=global_query_review \
--review-history D=slow_query_log,t=global_query_review_history \
--no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /data/log/mysql/slow.log.1
endscript
This will allow you to view slow queries via my.ttlsa.com/anemometer.
About "how to use Anemometer to analyze MySQL slow query records" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.