MySQL Server Optimieren mit Tuning-primer.sh

mysqlJetzt wird es mal wieder ein wenig technisch: Heute musste ich meinen Server neu installieren, da durch eine Sicherheitslücke in ProFTP ein Rootkit eingeschleust wurde.

Mittlerweile läuft wieder alles, bin nebenbei wieder von OpenSuse nach Debian gewechselt, allerdings lässt die Mysql Performance in der Standard Konfiguration sehr zu wünschen übrig.

Ein Skript welches mir beim Finden der optimalen Einstellungen sehr hilft ist tuning-primer.sh.

Hier seht Ihr kurz die Installation und ein Beispiel für den Einsatz:

cd /usr/bin

wget http://www.day32.com/MySQL/tuning-primer.sh

chmod +x tuning-primer.sh

./tuning-primer.sh

Sollte es zu Fehlern bei der Ausführung kommen, so muss ggf. noch bc nachinstalliert werden:

apt-get install bc

Wichtig für die Analyse ist, dass Mysql schon eine ganze Weile gelaufen ist und die Buffer sich gefüllt haben. Bei mir sieht die Ausgabe des Skripts zur Zeit so aus:

— MYSQL PERFORMANCE TUNING PRIMER —
– By: Matthew Montgomery –

MySQL Version 5.0.51a-24+lenny4 i486

Uptime = 0 days 0 hrs 0 min 5 sec
Avg. qps = 138
Total Questions = 692
Threads Connected = 6

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL’s Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10 sec.
You have 0 out of 752 that take longer than 10 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 64
Current threads_cached = 1
Current threads_per_sec = 0
Historic threads_per_sec = 1
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 500
Current threads_connected = 4
Historic max_used_connections = 6
The number of used connections is 1% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See „MEMORY USAGE“ section to make sure you are not over-allocating

INNODB STATUS
Current InnoDB index space = 1 M
Current InnoDB data space = 2 M
Current InnoDB buffer pool free = 0 %
Current innodb_buffer_pool_size = 2 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 77 M
Configured Max Per-thread Buffers : 2.13 G
Configured Max Global Buffers : 50 M
Configured Max Memory Limit : 2.18 G
Physical Memory : 6.00 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 1.24 G
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 9
Key buffer free ratio = 83 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 32 M
Current query_cache_used = 1 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 3.95 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won’t cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 1.00 M
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly

OPEN FILES LIMIT
Current open_files_limit = 6000 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_cache value = 2048 tables
You have a total of 1881 tables
You have 1899 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 256 temp tables, 13% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 1020 K
Current table scan ratio = 169 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 0 : 1754
Your table locking seems to be fine

Wie Ihr seht läuft mein Server noch nicht solange, doch einige Einstellungen kann man bereits jetzt schon in der my.cnf vornehmen.

Eine Pauschale Empfehlung für die Konfiguration kann man nicht geben, da sie sich je nach RAM, Anwendungsbereich und Datenbanken stark unterscheidet. Daher am besten gelegentlich das Skript aufrufen und Feintuning betreiben.

Teile deine Gedanken

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.