您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)mysqlsla如何安裝與使用的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
mysqlsla的安裝與使用
1. mysqlsla
[root@localhost tmp]# wget http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
--19:45:45-- http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
Resolving hackmysql.com... 64.13.232.157
Connecting to hackmysql.com|64.13.232.157|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 33674 (33K) [application/x-tar]
Saving to: `mysqlsla-2.03.tar.gz.2'
100%[===========================================================================================>] 33,674 50.2K/s in 0.7s
19:45:47 (50.2 KB/s) - `mysqlsla-2.03.tar.gz.2' saved [33674/33674]
2.解壓
[root@localhost tmp]# tar -zxvf mysqlsla-2.03.tar.gz
mysqlsla-2.03/
mysqlsla-2.03/Changes
mysqlsla-2.03/INSTALL
mysqlsla-2.03/README
mysqlsla-2.03/Makefile.PL
mysqlsla-2.03/bin/
mysqlsla-2.03/bin/mysqlsla
mysqlsla-2.03/META.yml
mysqlsla-2.03/lib/
mysqlsla-2.03/lib/mysqlsla.pm
mysqlsla-2.03/MANIFEST
[root@localhost tmp]# cd mysqlsla-2.03
[root@localhost mysqlsla-2.03]# ls
bin Changes INSTALL lib Makefile.PL MANIFEST META.yml README
3.執(zhí)行perl腳本檢查包依賴關(guān)系
[root@localhost mysqlsla-2.03]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for mysqlsla
4.安裝
[root@localhost mysqlsla-2.03]# make && make install;
cp lib/mysqlsla.pm blib/lib/mysqlsla.pm
cp bin/mysqlsla blib/script/mysqlsla
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/mysqlsla
Manifying blib/man3/mysqlsla.3pm
Installing /usr/lib/perl5/site_perl/5.8.8/mysqlsla.pm
Installing /usr/share/man/man3/mysqlsla.3pm
Installing /usr/bin/mysqlsla
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/mysqlsla/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
[root@localhost mysqlsla-2.03]#
5.簡(jiǎn)單使用
語(yǔ)法:
Slow log: mysqlsla -lt slow slow.log
General log: mysqlsla -lt general general.log
Binary log: mysqlbinlog bin.log | mysqlsla -lt binary -
這里以slow log為例:
[root@localhost mysqlsla-2.03]# mysqlsla -lt slow /tmp/127_slow.log | more
Report for slow logs: /tmp/127_slow.log
24 queries total, 6 unique
Sorted by 't_sum'
Grand Totals: Time 16 s, Lock 1 s, Rows sent 18, Rows Examined 2.10M
______________________________________________________________________ 001 ___
Count : 18 (75.00%)
Time : 15 s total, 833.333 ms avg, 0 to 8 s max (93.75%)
95% of Time : 7 s total, 411.765 ms avg, 0 to 4 s max
Lock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%)
95% of Lock : 0 total, 0 avg, 0 to 0 max
Rows sent : 0 avg, 0 to 0 max (0.00%)
Rows examined : 116.51k avg, 8 to 1.05M max (99.99%)
Database :
Users :
root@localhost : 100.00% (18) of query, 100.00% (24) of all users
Query abstract:
INSERT INTO t2 SELECT * FROM t2;
Query sample:
insert into t2 select * from t2;
........
選項(xiàng)說(shuō)明:
總查詢次數(shù) (queries total), 去重后的sql數(shù)量 (unique)
輸出報(bào)表的內(nèi)容排序(sorted by)
最重大的慢sql統(tǒng)計(jì)信息, 包括 平均執(zhí)行時(shí)間, 等待鎖時(shí)間, 結(jié)果行的總數(shù), 掃描的行總數(shù).
Count, sql的執(zhí)行次數(shù)及占總的slow log數(shù)量的百分比.
Time, 執(zhí)行時(shí)間, 包括總時(shí)間, 平均時(shí)間, 最小, 最大時(shí)間, 時(shí)間占到總慢sql時(shí)間的百分比.
95% of Time, 去除最快和最慢的sql, 覆蓋率占95%的sql的執(zhí)行時(shí)間.
Lock Time, 等待鎖的時(shí)間.
95% of Lock , 95%的慢sql等待鎖時(shí)間.
Rows sent, 結(jié)果行統(tǒng)計(jì)數(shù)量, 包括平均, 最小, 最大數(shù)量.
Rows examined, 掃描的行數(shù)量.
Database, 屬于哪個(gè)
Users, 哪個(gè)用戶,IP, 占到所有用戶執(zhí)行的sql百分比
Query abstract, 抽象后的sql語(yǔ)句
Query sample, sql語(yǔ)句
sla常用參數(shù)說(shuō)明:
1) -log-type (-lt) type logs:
通過(guò)這個(gè)參數(shù)來(lái)制定log的類型,主要有slow, general, binary, msl, udl,分析slow log時(shí)通過(guò)制定為slow.
2) -sort:
制定使用什么參數(shù)來(lái)對(duì)分析結(jié)果進(jìn)行排序,默認(rèn)是按照t_sum來(lái)進(jìn)行排序。
t_sum:按總時(shí)間排序
c_sum:按總次數(shù)排序
c_sum_p: sql語(yǔ)句執(zhí)行次數(shù)占總執(zhí)行次數(shù)的百分比。
3) -top:
顯示sql的數(shù)量,默認(rèn)是10,表示按規(guī)則取排序的前多少條
4) –statement-filter (-sf) [+-][TYPE]:
過(guò)濾sql語(yǔ)句的類型,比如select、update、drop.
[TYPE]有SELECT, CREATE, DROP, UPDATE, INSERT,例如"+SELECT,INSERT",不出現(xiàn)的默認(rèn)是-,即不包括。
5) db:要處理哪個(gè)庫(kù)的日志:
例如,只取backup庫(kù)的select語(yǔ)句、按c_sum_p排序的前2條記錄
[root@localhost mysqlsla-2.03]# mysqlsla -lt slow -sort c_sum_p -sf "+select" -db backup -top 2 /tmp/127_slow.log
Report for slow logs: /tmp/127_slow.log
4 queries total, 3 unique
Sorted by 'c_sum_p'
Grand Totals: Time 1 s, Lock 1 s, Rows sent 18, Rows Examined 195
______________________________________________________________________ 001 ___
Count : 2 (50.00%)
Time : 0 total, 0 avg, 0 to 0 max (0.00%)
Lock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%)
Rows sent : 1 avg, 1 to 1 max (11.11%)
Rows examined : 86 avg, 77 to 94 max (87.69%)
Database :
Users :
root@localhost : 100.00% (2) of query, 100.00% (4) of all users
Query abstract:
SELECT SUM(format(duration,N)) AS duration FROM information_schema.profiling WHERE query_id=N;
Query sample:
select sum(format(duration,6)) as duration from information_schema.profiling where query_id=7;
______________________________________________________________________ 002 ___
Count : 1 (25.00%)
Time : 1 s total, 1 s avg, 1 s to 1 s max (100.00%)
Lock Time (s) : 1 s total, 1 s avg, 1 s to 1 s max (100.00%)
Rows sent : 4 avg, 4 to 4 max (22.22%)
Rows examined : 12 avg, 12 to 12 max (6.15%)
Database :
Users :
root@localhost : 100.00% (1) of query, 100.00% (4) of all users
Query abstract:
SELECT * FROM tt WHERE a=N;
Query sample:
select * from tt where a=2;
[root@localhost mysqlsla-2.03]#
[root@localhost mysqlsla-2.03]#
感謝各位的閱讀!關(guān)于“mysqlsla如何安裝與使用”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。