Optimale my.cnf Einstellungen

duese

New Member
Hallo,

ich habe einen Server der nur als Webserver benutzt wird, nun ist mir schon ein paar mal aufgefallen, wenn ein Besucher Sturm kommt, das die die MySQL die CPU kurze Zeit auf 100% macht.

In der my.cnf habe ich soweit nichts geändert, ausser "max_connections = 200" hinzugefügt.

Hier mal die Ausgabe vom tuning-primer.sh:

Code:
        -- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -

MySQL Version 5.0.32-Debian_7etch8-log i486

Uptime = 0 days 0 hrs 14 min 16 sec
Avg. qps = 170
Total Questions = 145958
Threads Connected = 2

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 146000 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.

BINARY UPDATE LOG
The binary update log is enabled

WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 7
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 200
Current threads_connected = 2
Historic max_used_connections = 21
The number of used connections is 10% 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

MEMORY USAGE
Max Memory Ever Allocated : 97 M
Configured Max Per-thread Buffers : 531 M
Configured Max Global Buffers : 42 M
Configured Max Memory Limit : 573 M
Physical Memory : 2.96 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 5 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 541
Key buffer fill ratio = 7.00 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere

QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 2 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 13.30 %
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 = 132.00 K
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 = 1024 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 = 64 tables
You have a total of 101 tables
You have 64 open tables.
Current table_cache hit rate is 17%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 1520 temp tables, 79% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 704 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 228
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2'.

/etc/init.d/mysql status sagt folgendes:
Code:
/usr/bin/mysqladmin  Ver 8.41 Distrib 5.0.32, for pc-linux-gnu on i486
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.32-Debian_7etch8-log
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 1 hour 38 min 22 sec

Threads: 46  Questions: 1053510  Slow queries: 5  Opens: 929  Flush tables: 1  Open tables: 78  Queries per second avg: 178.501.

Der Server verfügt über 2GB Ram, benutzt wird meistens ca. 400MB Ram, wenn die CPU wegen der MySQL auf 100 ist, dann kann es auch mal 700 Ram sein. CPU: Intel(R) Pentium(R) Dual CPU E2200 @ 2.20GHz

Vielleicht hat ja jemand ein Tipp was ich in der my.cnf ändern könnte das der zb. die Anfragen schneller beantwortet.

Würde mich über eine Antwort freuen!

Liebe Grüße,
duese
 
Last edited by a moderator:
was du in der my.cnf ändern könnstest

Code:
thread_cache_size = 32 [COLOR="Red"]kannst auch mit 128 testen[/COLOR]
table_cache = 1024
low_priority_updates=1 [COLOR="Red"]oder[/COLOR]
concurrent_insert=2

join_buffer und read_buffer kannst du auch mal größer testen.

Apache konfigurieren

Code:
Timeout 30
KeepAlive On
MaxKeepAliveRequests 150
KeepAliveTimeout 2

und Apache Module deaktivieren, welche nicht benötigt werden.

Anleitung
 
Last edited by a moderator:
Back
Top