cnetos7安装mysqlsla

来源:互联网 发布:天刀最丑捏脸数据下载 编辑:程序博客网 时间:2024/06/04 18:56

1,安装环境准备:mysqlsla用的是perl语言,需要perl-DBI和perl-DBD-Mysql模块支持
安装perl支持 
一:转载自 http://www.centoscn.com/image-text/install/2015/0707/5808.html

1、安装Perl环境

yum install perl*
这个命令基本上把perl的模块给安装齐了。
yum install cpan
CPAN这个就不用说了吧,大家都懂。


如果你对perl模块版本要求比较高,希望是新版的那么请按照一下安装:
yum install perl
yum install cpan

以后有什么需要直接用cpan编译安装。

 

2、下载安装最新Perl版本

首先下载最新的perl源码包:


[root@akinlau /]# wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz


解压源码包
[root@akinlau /]# tar -xzf perl-5.16.1.tar.gz


编译并安装,目录可以自定义


[root@akinlau /]# cd perl-5.16.1
[root@akinlau perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl


[root@akinlau perl-5.16.1]# make
[root@akinlau perl-5.16.1]# make test
[root@akinlau perl-5.16.1]# make install


如果系统以前已安装了旧版本的perl的话,替换系统原有的版本。
[root@akinlau perl-5.16.1]# mv /usr/bin/perl /usr/bin/perl.bak
[root@akinlau perl-5.16.1]# ln -s /usr/local/perl/bin/perl /usr/bin/perl


再看看是不是最新的版本


[root@akinlau perl-5.16.1]# perl -v


This is perl 5, version 16, subversion 1 (v5.16.1) built for x86_64-linux


Copyright 1987-2012, Larry Wall


Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.


Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.




如果看到以上信息,就证明安装成功了

二:最新的mysqlsla文件已经移动的github上了,我们可以直接去github下载解压好的mysqlsla文件
      地址:https://github.com/daniel-nichter/hackmysql.com

三:移动到mysqlsla目录下:
1.perl Makefile.PL  #配置
出现错误请参照第一步;

make  #编译

make install  #安装

2.使用mysqlsla分析MySQL慢查询日志

#查询记录最多的20个sql语句,并写到select.log中去

mysqlsla -lt slow --sort t_sum --top 20  /data/mysql/127-slow.log >/tmp/select.log

#统计慢查询文件为/data/mysql/127-slow.log的所有select的慢查询sql,并显示执行时间最长的100条sql,并写到sql_select.log中去

mysqlsla -lt slow  -sf "+select" -top 100  /data/mysql/127-slow.log >/tmp/sql_select.log

#统计慢查询文件为/data/mysql/127-slow.log的数据库为mydata的所有select和update的慢查询sql,并查询次数最多的100条sql,并写到sql_num.sql中去

mysqlsla -lt slow  -sf "+select,update" -top 100 -sort c_sum  -db mydata /data/mysql/127-slow.log >/tmp/sql_num.log

0 0
原创粉丝点击