CentOs 7.6
mysql 8
perl-DBD-MySQL
percona-toolkit
Query-Digest-UI
yum install -y perl-DBD-MySQL-4.050-1.el7.x86_64.rpm
yum install -y percona-toolkit-3.3.0-1.el7.x86_64.rpm
git clone https://github.com/kormoc/Query-Digest-UI.git
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‘,
);
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
出现问题: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
原文:https://www.cnblogs.com/zheng-qi/p/14419932.html