Menü Schließen

MySQL – Server Zustand und Optimierung mittels Mysqltuner Script

MySQL Logo

Mittels dem Projekt “MysqlTuner-Perl” Script ist es möglich einen schnellen Überblick über den MySQL Server und dessen aktueller Leistung zu erhalten. Es werden diverse Einstellungen ausgewertet und an Hand der aktuellen Werte der Storage Engine Statistics, Security Empfehlungen und Ansätze zur Performance Optimierung, gegeben. Nachfolgend kurz die Einrichtung / Installation und ein Beispiel eines Durchlaufs unter Debian.

Installation – direkt von der Projektseite

# wget -O mysqltuner.tar.gz  https://github.com/major/MySQLTuner-perl/tarball/master && tar -xf mysqltuner.tar.gz

Installation – über die Debian Paketquellen

# aptitude install mysqltuner

Nun haben wir die Perl-Datei “mysqltuner.pl”, ggf. noch in einem Verzeichnis liegend.

Durchlauf des Scriptes:

-entweder mittels:  # perl mysqltuner.pl

– oder zuvor als ausführbar gekennzeichnet mit:
# chmod +x mysqltuner.pl
# ./mysqltuner.pl

>>  MySQLTuner 1.3.0 – Major Hayden <major@mhtx.net>
>>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
>>  Run with ‘–help’ for additional options and output filtering
[OK] Logged in using credentials from debian maintenance account.
[OK] Currently running supported MySQL version 5.1.73-1
[OK] Operating on 64-bit architecture

——– Storage Engine Statistics ——————————————-
[–] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[–] Data in MyISAM tables: 542M (Tables: 798)
[–] Data in InnoDB tables: 21M (Tables: 146)
[–] Data in MEMORY tables: 0B (Tables: 4)
[!!] Total fragmented tables: 208

——– Security Recommendations  ——————————————-
[OK] All database users have passwords assigned

——– Performance Metrics ————————————————-
[–] Up for: 57d 12h 30m 23s (130M q [26.164 qps], 3M conn, TX: 404B, RX: 24B)
[–] Reads / Writes: 66% / 34%
[–] Total buffers: 58.0M global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 463.8M (8% of installed RAM)
[OK] Slow queries: 0% (253/130M)
[OK] Highest usage of available connections: 30% (46/151)
[OK] Key buffer size / total MyISAM indexes: 16.0M/88.8M
[OK] Key buffer hit rate: 99.6% (2B cached / 7M reads)
[OK] Query cache efficiency: 78.8% (83M cached / 106M selects)
[!!] Query cache prunes per day: 101521
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 7M sorts)
[!!] Joins performed without indexes: 1175547
[OK] Temporary tables created on disk: 23% (2M on disk / 9M total)
[OK] Thread cache hit rate: 99% (4K created / 3M connections)
[!!] Table cache hit rate: 0% (64 open / 1M opened)
[OK] Open file limit used: 11% (116/1K)
[OK] Table locks acquired immediately: 99% (54M immediate / 55M locks)
[!!] InnoDB  buffer pool / data size: 8.0M/21.9M
[OK] InnoDB log waits: 0
——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
Adjust your join queries to always utilize indexes
Increase table_cache gradually to avoid file descriptor limits
Read this before increasing table_cache over 64: http://bit.ly/1mi7c4C
Variables to adjust:
query_cache_size (> 16M)
join_buffer_size (> 128.0K, or always use indexes with joins)
table_cache (> 64)
innodb_buffer_pool_size (>= 21M)

Benutzer und Passwort fest hinterlegen

Wer hier nach einem Passwort gefragt wird, kann in seinem Homeverzeichnis eine eine “.my.cnf” anlegen und dort folgende Zeilen eintragen:

[client]
user=someusername
pass=thatuserspassword

Danach sollte das mysqltuner.pl Script nicht mehr nach den Zugangsdaten fragen.

Webseite: http://mysqltuner.com/

Wer es etwas ausführlicher und umfassend wünscht der kann sich das MySQL Performance Tuning Primer Script ansehen.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert