Apache2 + MySQL-Konfiguration

Fireball22

Registered User
Hallo Leute,

auf meinem Strato-V-Server A läuft Debian 4.0 inkl. Plesk 8 und leider killt sich in den letzten Tagen verhäuft der Apache2 ab, da nicht mehr ausreichend RAM für Childprozesse zur Verfügung steht.

Ausschnitt aus der Log:
Code:
[Tue Jul 01 20:42:30 2008] [emerg] (12)Cannot allocate memory: couldn't grab the accept mutex
[Tue Jul 01 20:42:31 2008] [alert] Child 7998 returned a Fatal error... Apache is exiting!
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:32 2008] [emerg] (43)Identifier removed: couldn't grab the accept mutex
[Tue Jul 01 20:42:42 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:44 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:44 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:44 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:44 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:45 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:50 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:42:51 2008] [emerg] (22)Invalid argument: couldn't release the accept mutex
[Tue Jul 01 20:43:13 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:13 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:14 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:17 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:20 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:41 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
[Tue Jul 01 20:43:41 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex

Allerdings würde ich schon gerne die gleiche Performance meines Apaches und des MySQL-Servers beibehalten.

Deshalb wollte ich fragen, wo man noch kleinere Eingriffe in der Konfiguration vornehmen kann, um den RAM-Verbrauch einzuschränken bzw. einfach das Abstürzen des Apaches zu vermeiden.

Hier Auszüge aus der Apache2 Config:
Code:
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

User www-data
Group www-data

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

TypesConfig /etc/mime.types

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

Und aus der MySQL-Config:

Code:
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address          = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 128K
thread_cache_size       = 8
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log            = /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
#
# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
#server-id              = 1
log_bin                 = /var/log/mysql/mysql-bin.log
# WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
#skip-innodb
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2
[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer              = 16M

#
# * NDB Cluster
#
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# not from the NDB Management Nodes (ndb_mgmd processes).
#
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1

So sieht es im Moment mit der Speicherverteilung aus:

Code:
VPS Speichernutzung:
Momentan genutzt:       319,875 MB
Zugesichert:            259,375 MB
Maximal nutzbar:        791,281 MB

Ich würde mich über eure Hilfe sehr freuen!

MfG
Michael
 
Da es für dich zu 100% gilt:

Allerdings würde ich schon gerne die gleiche Performance meines Apaches und des MySQL-Servers beibehalten.
Ich habe ein Fahrrad und will 200 km/h schnell fahren...
Irgendwo musst du Kompromisse schließen.
 
Tut mir leid, da bekomme ich leider nur Konfigurationsvorschläge für Server mit 1 GB RAM und nicht für einen V-Server.
 
Als erstes solltest Du das tuning-primer.sh-Script anwenden, und danach behutsam mit den Werten der Apache-Config experimentieren. Die genannten Threads geben Dir dabei Anhaltspunkte, da dort die Bedeutung der einzelnen Parameter erklärt werden (ebenso in der online-Doku des Apachen).
Wie Du die Werte genau setzten musst, kann Dir ohnehin niemand sagen, da niemand außer Dir die genaue Auslastung, etc. Deines vServers kennt.
 
Okay, werde naher gleich mal einige Dinge zu dem Apache durchlesen.

Das ist die Ausgabe vom tuning-primer-Script:

Code:
h852677:~# sh tuning-primer.sh
mysqld is alive

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

MySQL Version 5.0.32-Debian_7etch5-log i486

tuning-primer.sh: line 389: bc: command not found
tuning-primer.sh: line 390: bc: command not found
tuning-primer.sh: line 391: bc: command not found
tuning-primer.sh: line 392: bc: command not found
tuning-primer.sh: line 393: bc: command not found
tuning-primer.sh: line 394: bc: command not found
Uptime =  days  hrs  min  sec
Avg. qps = 0
Total Questions = 2104497
Threads Connected = 1

Server has been running for over 48hrs.
It should be safe to follow 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 2104518 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 = 100
Current threads_connected = 1
Historic max_used_connections = 14
The number of used connections is 14% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
tuning-primer.sh: line 1205: bc: command not found
tuning-primer.sh: line 1206: bc: command not found
tuning-primer.sh: line 1230: bc: command not found
tuning-primer.sh: line 1233: bc: command not found
tuning-primer.sh: line 1234: bc: command not found
tuning-primer.sh: line 1236: bc: command not found
tuning-primer.sh: line 1238: [: -gt: unary operator expected
tuning-primer.sh: line 351: [: max_memoryHR: integer expression expected
tuning-primer.sh: line 357: [: max_memoryHR: integer expression expected
tuning-primer.sh: line 363: [: max_memoryHR: integer expression expected
tuning-primer.sh: line 370: export: `0=max_memoryHR': not a valid identifier
Max Memory Ever Allocated :  bytes
tuning-primer.sh: line 351: [: per_thread_buffersHR: integer expression expected
tuning-primer.sh: line 357: [: per_thread_buffersHR: integer expression expected
tuning-primer.sh: line 363: [: per_thread_buffersHR: integer expression expected
tuning-primer.sh: line 370: export: `0=per_thread_buffersHR': not a valid identifier
Configured Max Per-thread Buffers :  bytes
tuning-primer.sh: line 351: [: global_buffersHR: integer expression expected
tuning-primer.sh: line 357: [: global_buffersHR: integer expression expected
tuning-primer.sh: line 363: [: global_buffersHR: integer expression expected
tuning-primer.sh: line 370: export: `0=global_buffersHR': not a valid identifier
Configured Max Global Buffers :  bytes
tuning-primer.sh: line 351: [: total_memoryHR: integer expression expected
tuning-primer.sh: line 357: [: total_memoryHR: integer expression expected
tuning-primer.sh: line 363: [: total_memoryHR: integer expression expected
tuning-primer.sh: line 370: export: `0=total_memoryHR': not a valid identifier
Configured Max Memory Limit :  bytes
tuning-primer.sh: line 332: bc: command not found
Physical Memory :  G
Max memory limit seem to be within acceptable norms

KEY BUFFER
tuning-primer.sh: line 332: bc: command not found
tuning-primer.sh: line 647: bc: command not found
tuning-primer.sh: line 648: bc: command not found
tuning-primer.sh: line 332: bc: command not found
Current MyISAM index space =  M
tuning-primer.sh: line 332: bc: command not found
Current key_buffer_size =  M
Key cache miss rate is 1 : 729
Key buffer fill ratio =  %
tuning-primer.sh: line 685: [: -ge: unary operator expected
tuning-primer.sh: line 689: [: -le: unary operator expected
Your key_buffer_size seems to be fine

QUERY CACHE
tuning-primer.sh: line 720: bc: command not found
tuning-primer.sh: line 721: bc: command not found
Query cache is enabled
tuning-primer.sh: line 332: bc: command not found
Current query_cache_size =  M
tuning-primer.sh: line 332: bc: command not found
Current query_cache_used =  M
tuning-primer.sh: line 332: bc: command not found
Current query_cache_limit =  M
Current Query cache Memory fill ratio =  %
tuning-primer.sh: line 332: bc: command not found
Current query_cache_min_res_unit =  K
tuning-primer.sh: line 734: bc: command not found
tuning-primer.sh: line 735: bc: command not found
tuning-primer.sh: line 736: [: -gt: unary operator expected
tuning-primer.sh: line 743: [: -le: unary operator expected
tuning-primer.sh: line 747: [: -ge: unary operator expected
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
tuning-primer.sh: line 332: bc: command not found
Current sort_buffer_size =  M
tuning-primer.sh: line 332: bc: command not found
Current read_rnd_buffer_size =  K
Sort buffer seems to be fine

JOINS
tuning-primer.sh: line 332: bc: command not found
Current join_buffer_size =  K
You have had 980 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

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 657 tables
You have 64 open tables.
Current table_cache hit rate is 0%, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
tuning-primer.sh: line 332: bc: command not found
Current max_heap_table_size =  M
tuning-primer.sh: line 332: bc: command not found
Current tmp_table_size =  M
Of 101786 temp tables, 49% 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
tuning-primer.sh: line 332: bc: command not found
Current read_buffer_size =  K
Current table scan ratio = 2418 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 1887
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'.

Leider kann ich mit den Meldungen nicht sehr viel anfangen und weiß nicht, was ich wirklich ändern sollte oder ob diese Einstellung für einen V-Server okay ist.

MfG
Michael
 
Hallo!
Das ist aber jetzt ein Indiz darür, dass du eben noch nicht die Beiträge im Forum gelesen hast. Dir fehlt das bc Paket für deine Distribution.

mfG
Thorsten
 
Sorry, das habe ich leider echt nicht gelesen.

Hier nun aber die vollständige Ausgabe des Scripts:

Code:
mysqld is alive

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

MySQL Version 5.0.32-Debian_7etch5-log i486

Uptime = 29 days 19 hrs 39 min 21 sec
Avg. qps = 0
Total Questions = 2106929
Threads Connected = 1

Server has been running for over 48hrs.
It should be safe to follow 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 2106950 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 = 100
Current threads_connected = 1
Historic max_used_connections = 14
The number of used connections is 14% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
Max Memory Ever Allocated : 72 M
Configured Max Per-thread Buffers : 265 M
Configured Max Global Buffers : 34 M
Configured Max Memory Limit : 300 M
Physical Memory : 1.97 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 1 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 724
Key buffer fill ratio = 0 %
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 = 5 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 32.80 %
Current query_cache_min_res_unit = 4 K
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 981 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.

Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.

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 657 tables
You have 64 open tables.
Current table_cache hit rate is 0%, 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 101926 temp tables, 49% 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 = 2418 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 1823
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'.

Gibt es denn nicht auch so ein Test-Script für den Apache?

MfG
Michael
 
Back
Top