martes, 14 de septiembre de 2010

Centos 5.x: MySQL Tools

Vamos viendo que herramientas podemos usar para saber el desempeño de MySQL, vamos empezando por: msqlreport.

Lo bajamos del site: http://hackmysql.com/mysqlreport

Descomprimimos y empezamos a trabajar sobre el:

#./mysqlreport
./mysqlreport
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at (eval 7) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.
at ./mysqlreport line 249

Bien, vamos a ver necesitamos instalar los siguientes paquetes antes de continuar:

yum install perl-DBD-mysql

Ahora ejecutamos ahora si el programa con los parametros del servidor:

./mysqlreport --user username --password mipassword

Use of uninitialized value in multiplication (*) at ./mysqlreport line 829.
Use of uninitialized value in formline at ./mysqlreport line 1227.
MySQL 5.1.50-community- uptime 0 6:19:10 Tue Sep 14 23:30:32 2010

__ Key _________________________________________________________________
Buffer used 28.00k of 384.00M %Used: 0.01
Current 71.85M %Usage: 18.71
Write hit 35.75%
Read hit 94.88%

__ Questions ___________________________________________________________
Total 3.05k 0.1/s
Com_ 1.64k 0.1/s %Total: 53.82
QC Hits 630 0.0/s 20.66
DMS 458 0.0/s 15.02
COM_QUIT 327 0.0/s 10.72
-Unknown 7 0.0/s 0.23
Slow 10 s 1 0.0/s 0.03 %DMS: 0.22 Log: OFF
DMS 458 0.0/s 15.02
SELECT 395 0.0/s 12.96 86.24
INSERT 33 0.0/s 1.08 7.21
DELETE 27 0.0/s 0.89 5.90
UPDATE 2 0.0/s 0.07 0.44
REPLACE 1 0.0/s 0.03 0.22
Com_ 1.64k 0.1/s 53.82
set_option 611 0.0/s 20.04
show_tables 232 0.0/s 7.61
change_db 192 0.0/s 6.30

Scan 719 0.0/s %SELECT: 182.03
Range 0 0/s 0.00
Full join 0 0/s 0.00
Range check 0 0/s 0.00
Full rng join 0 0/s 0.00
Sort scan 18 0.0/s
Sort range 0 0/s
Sort mrg pass 0 0/s

__ Query Cache _________________________________________________________
Memory usage 165.27k of 32.00M %Used: 0.50
Block Fragmnt 1.70%
Hits 630 0.0/s
Inserts 197 0.0/s
Insrt:Prune 197:1 0.0/s
Hit:Insert 3.20:1

__ Table Locks _________________________________________________________
Waited 0 0/s %Total: 0.00
Immediate 536 0.0/s

__ Tables ______________________________________________________________
Open 35 of 512 %Cache: 6.84
Opened 51 0.0/s

__ Connections _________________________________________________________
Max used 4 of 151 %Max: 2.65
Total 329 0.0/s

__ Created Temp ________________________________________________________
Disk table 143 0.0/s
Table 687 0.0/s Size: 16.0M
File 5 0.0/s

__ Threads _____________________________________________________________
Running 1 of 1
Cached 3 of 8 %Hit: 98.78
Created 4 0.0/s
Slow 0 0/s

__ Aborted _____________________________________________________________
Clients 0 0/s
Connects 10 0.0/s

__ Bytes _______________________________________________________________
Sent 1.80M 79.3/s
Received 245.42k 10.8/s

__ InnoDB Buffer Pool __________________________________________________
Usage 304.00k of 8.00M %Used: 3.71
Read hit 84.42%
Pages
Free 493 %Total: 96.29
Data 19 3.71 %Drty: 0.00
Misc 0 0.00
Latched 0.00
Reads 77 0.0/s
From file 12 0.0/s 15.58
Ahead Rnd 1 0.0/s
Ahead Sql 0 0/s
Writes 0 0/s
Flushes 0 0/s
Wait Free 0 0/s

__ InnoDB Lock _________________________________________________________
Waits 0 0/s
Current 0
Time acquiring
Total 0 ms
Average 0 ms
Max 0 ms

__ InnoDB Data, Pages, Rows ____________________________________________
Data
Reads 25 0.0/s
Writes 3 0.0/s
fsync 3 0.0/s
Pending
Reads 0
Writes 0
fsync 0

Pages
Created 0 0/s
Read 19 0.0/s
Written 0 0/s

Rows
Deleted 0 0/s
Inserted 0 0/s
Read 0 0/s
Updated 0 0/s

Le toca el turno a mysqltuner, lo bajamos de:

http://blog.mysqltuner.com/

Lo ponemos en modo script:

chmod +x mysqltuner.pl

./mysqltuner.pl

>> MySQLTuner 1.0.1 - Major Hayden
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.50-community-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 924B (Tables: 9)
[!!] InnoDB is enabled but isn't being used
[OK] Total fragmented tables: 0

-------- Performance Metrics -------------------------------------------------
[--] Up for: 15m 18s (28 q [0.031 qps], 15 conn, TX: 26K, RX: 1K)
[--] Reads / Writes: 100% / 0%
[--] Total buffers: 1.4G global + 12.4M per thread (151 max threads)
[!!] Maximum possible memory usage: 3.3G (167% of installed RAM)
[!!] Slow queries: 10% (3/28)
[OK] Highest usage of available connections: 0% (1/151)
[OK] Key buffer size / total MyISAM indexes: 384.0M/120.0K
[!!] Query cache efficiency: 0.0% (0 cached / 14 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1 sorts)
[OK] Temporary tables created on disk: 0% (0 on disk / 8 total)
[OK] Thread cache hit rate: 93% (1 created / 15 connections)
[OK] Table cache hit rate: 82% (32 open / 39 opened)
[OK] Open file limit used: 5% (68/1K)
[OK] Table locks acquired immediately: 100% (18 immediate / 18 locks)
[!!] Connections aborted: 13%

-------- Recommendations -----------------------------------------------------
General recommendations:
Add skip-innodb to MySQL configuration to disable InnoDB
MySQL started within last 24 hours - recommendations may be inaccurate
Reduce your overall MySQL memory footprint for system stability
Your applications are not closing MySQL connections properly
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_limit (> 1M, or use smaller result sets)

Ahora le toca a innotop este lo bajamos de:

http://code.google.com/p/innotop/downloads/list

Descomprimimos y vemos que necesitamos:

perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Term::ReadKey 2.1 not found.
Writing Makefile for innotop

Necesitamos instalar:

yum install perl-TermReadKey

Ahora si lo instalamos:

make install
cp innotop blib/script/innotop
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/innotop
Manifying blib/man1/innotop.1
Installing /usr/share/man/man1/innotop.1
Installing /usr/bin/innotop
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/innotop/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

Probando:

innotop --u root --password mi-password

When Load QPS Slow QCacheHit KCacheHit BpsIn BpsOut
Total 0.00 0.12 0 42.86% 100.00% 5.27 82.19

Cmd ID State User Host DB Time Query
Daemon 1 Waiting on empty q event_sc localhost 14:31

Listo.

Ahora le toca el turno a mysqlsla, este lo bajamos de:

http://hackmysql.com/mysqlsla

Lo mismo, descomprimimos y a instalar, leer el INSTALL ee.

perl Makefile.PL
Checking if your kit is complete...
Looks good

make
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

make install
Installing /usr/lib/perl5/site_perl/5.8.8/mysqlsla.pm
Installing /usr/share/man/man3/mysqlsla.3pm
Installing /usr/bin/mysqlsla
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/mysqlsla/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

Probamos:

mysqlsla --log-type slow
Report for slow logs:
0 queries total, 0 unique
Sorted by 't_sum'
Grand Totals: Time 0 s, Lock 0 s, Rows sent 0, Rows Examined 0

Aun no tenemos nada listo, pero ahi esta corriendo.

Otro mas mytop y mtop.

super-smack.

Debemos copear el archivo /usr/share/smack/select-key.smack ahi mismo con el nombre select-key-mysql.smack.

Editarlo a nuestros parametros.

Y por ejemplo ejecutarlo asi:

super-smack -d mysql select-key-mysql.smack 10 1000

Query Barrel Report for client smacker1
connect: max=203ms min=0ms avg= 43ms from 10 clients
Query_type num_queries max_time min_time q_per_s
select_index 20000 0 0 38950.44

Aqui genera una tabla myisam.

Le toca el turno a sysbench, Centos 5.5 tiene la 0.4.10, del sitio podemos descargar la 0.4.12, es lo que vamos hacer e instalar.

Leyendo el INSTALL del src dice que debemos hacer esto:

1; Desempaquetar el archivo .tar.gz.
2; Entrar a el directorio creado.
3; Ejecutar:
./configure
4; Ejecutar
make ---->Pero antes de instalar libtool,autocof,gcc,gcc-c++ con yum.
5; make install

Listo ya tenemos a sysbench operable.

Vamos a generar una tabla de nombre sbtest como dice el manual con




No hay comentarios: