首页 > 其他 > 详细

pt-query-digest安装使用及可视化

时间:2021-02-20 16:07:47      阅读:41      评论:0      收藏:0      [点我收藏+]

系统环境

CentOs 7.6
mysql 8

安装包下载

perl-DBD-MySQL
percona-toolkit
Query-Digest-UI

安装

安装perl-DBD-MySQL(连接mysql8需要)

yum install -y perl-DBD-MySQL-4.050-1.el7.x86_64.rpm

安装percona-toolkit

yum install -y percona-toolkit-3.3.0-1.el7.x86_64.rpm

安装Query-Digest-UI

下载

git clone https://github.com/kormoc/Query-Digest-UI.git

移动文件到/var/www/html目录(apache默认根目录),并改名为slow。

mv Query-Digest-UI /var/www/html/slow

修改配置文件

cd /var/www/html/slow
cp config.php.example config.php
vi config.php
$reviewhost = array(
// Replace hostname and database in this setting
// use host=hostname;port=portnum if not the default port
    ‘dsn‘           => ‘mysql:host=localhost;port=13306;dbname=test‘,
    ‘user‘          => ‘monitor‘,
    ‘password‘      => ‘monitor‘,
// See http://www.percona.com/doc/percona-toolkit/2.1/pt-query-digest.html#cmdoption-pt-query-digest--review
// 表 query_review 为 pt-query-digest --review 操作时生成
    ‘review_table‘  => ‘query_review‘,
// This table is optional. You don‘t need it, but you lose detailed stats
// Set to a blank string to disable
// See http://www.percona.com/doc/percona-toolkit/2.1/pt-query-digest.html#cmdoption-pt-query-digest--review-history
// 表 query_review_history 为 pt-query-digest --history 操作时生成
    ‘history_table‘ => ‘query_history‘,
);

使用

使用pt-query-digest分析日志并将分析结果导入数据库

mysql创建新用户并授权,用于存放分析结果
技术分享图片
说明:mysql8采用 caching_sha2_password 方式认证,pt-query-digest不支持,故创建的用户应选用mysql_native_password方式

pt-query-digest --review  h=localhost,P=13306,D=test,u=monitor,p=monitor,t=query_review --create-review-table --history  h=localhost,P=13306,D=test,u=monitor,p=monitor,t=query_history --create-history-table --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" mysql-slow.log

Query-Digest-UI使用

出现问题:http://192.168.80.230/slow/ 访问不了
原因:apache网站默认无法访问,需要启用httpd服务
解决:

yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service

参考资料

Percona Toolkit工具连接MySQL 8报错的解决方案
关于linux的/var/www/html

pt-query-digest安装使用及可视化

原文:https://www.cnblogs.com/zheng-qi/p/14419932.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!