设为首页 收藏本站
查看: 578|回复: 0

[经验分享] [MySQL 工具] pt-query-digest使用出错问题分析Can't locate Time/HiRes.pm in @INC

[复制链接]

尚未签到

发表于 2016-10-24 03:23:07 | 显示全部楼层 |阅读模式
  pt-query-digest :分析查询执行日志,并产生一个查询报告
  


[iyunv@472322 percona-toolkit-2.2.5]# pt-query-digest --help
Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/pt-query-digest line 3187.

BEGIN failed--compilation aborted at /usr/local/bin/pt-query-digest line 3187.


解决方案:

.pm实际上是Perl的包,只需安装如下软件包即可:

yum install -y perl-Time-HiRes



[iyunv@472322 percona-toolkit-2.2.5]# yum install perl-Time-HiRes

Loaded plugins: dellsysid, fastestmirror, presto

Loading mirror speeds from cached hostfile

* base: mirror.rackspace.com

* dell-community: linux.dell.com

* epel: fedora-epel.mirror.lstn.net

* extras: mirrordenver.fdcservers.net

* updates: centos.mirror.lstn.net

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package perl-Time-HiRes.x86_64 4:1.9721-131.el6_4 will be installed

--> Finished Dependency Resolution



Dependencies Resolved



=======================================================================================================================================================================

Package                  Arch               Version                     Repository             Size

=======================================================================================================================================================================

Installing:

perl-Time-HiRes              x86_64              4:1.9721-131.el6_4               updates               47 k



............................... 此处省略..............................



Running Transaction

Installing : 4:perl-Time-HiRes-1.9721-131.el6_4.x86_64                                                      1/1

Verifying : 4:perl-Time-HiRes-1.9721-131.el6_4.x86_64                                                      1/1



Installed:

perl-Time-HiRes.x86_64 4:1.9721-131.el6_4                                                              



Complete!

Ok,可以查看pt-query-digest工具的功能介绍了:
[iyunv@472322 percona-toolkit-2.2.5]# pt-query-digest --help

pt-query-digest analyzes MySQL queries from slow, general, and binary log files.

It can also analyze queries from C<SHOW PROCESSLIST> and MySQL protocol data

from tcpdump. By default, queries are grouped by fingerprint and reported in

descending order of query time (i.e. the slowest queries first). If no C<FILES>

are given, the tool reads C<STDIN>. The optional C<DSN> is used for certain

options like L<"--since"> and L<"--until">. For more details, please use the

--help option, or try 'perldoc /usr/local/bin/pt-query-digest' for complete

documentation.



Usage: pt-query-digest [OPTIONS] [FILES] [DSN]



Options:



--ask-pass         Prompt for a password when connecting to MySQL

--attribute-aliases=a    List of attribute|alias,etc (default db|Schema)

--attribute-value-limit=i  A sanity limit for attribute values (default

4294967296)

--charset=s       -A Default character set

--config=A         Read this comma-separated list of config files;

if specified, this must be the first option on

the command line

--[no]continue-on-error   Continue parsing even if there is an error (

default yes)

--[no]create-history-table Create the --history table if it does not exist (

default yes)

--[no]create-review-table  Create the --review table if it does not exist (

default yes)

--daemonize         Fork to the background and detach from the shell

--database=s      -D Connect to this database

--defaults-file=s    -F Only read mysql options from the given file

--embedded-attributes=a   Two Perl regex patterns to capture pseudo-
  attributes embedded in queries
  ....................................
  

  分析本地的慢查询文件:
  

pt-query-digest --user=root --password=m@123 /data/dbdata/localhost-slow.log


  
  
重新回顾满查询日志,并将结果保存到query_review中,注意query_review表的表结构必须先建好,表结构如下:


CREATE TABLE query_review (
checksum     BIGINT UNSIGNED NOT NULL PRIMARY KEY,
fingerprint  TEXT NOT NULL,
sample       TEXT NOT NULL,
first_seen   DATETIME,
last_seen    DATETIME,
reviewed_by  VARCHAR(20),
reviewed_on  DATETIME,
comments     TEXT
);



命令如下:

pt-query-digest --user=root --password=m@123 --review h=localhost,D=test,t=query_review /data/dbdata/localhost-slow.log


  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-290290-1-1.html 上篇帖子: You have an error in your SQL syntax; check the manual that corresponds to your 下篇帖子: MySQL bigint types and iBATIS对ibatis关于BigInteger不支持的自定义处理方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表