MySQL se cae frecuentemente en VPS con zpanel y Wordpress

  • Autor Autor wbishop
  • Fecha de inicio Fecha de inicio
Te aconsejo que te pases por la comunidad de DigitalOcean, nos vemos por ahí! Por cierto, cuando haces service mysql restart que te sale?
 
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.5.37-0ubuntu0.12.04.1 x86_64

Uptime = 0 days 0 hrs 5 min 26 sec
Avg. qps = 4
Total Questions = 1454
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:
MySQL :: MySQL 5.5 Reference Manual :: 5.1.4 Server System Variables
Visit MySQL :: Page Not Found
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10.000000 sec.
You have 0 out of 1475 that take longer than 10.000000 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 MySQL :: MySQL 5.5 Reference Manual :: 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log

WORKER THREADS
Current thread_cache_size = 4
Current threads_cached = 2
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 151
Current threads_connected = 2
Historic max_used_connections = 4
The number of used connections is 2% 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 = 4 M
Current InnoDB data space = 20 M
Current InnoDB buffer pool free = 85 %
Current innodb_buffer_pool_size = 128 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 : 186 M
Configured Max Per-thread Buffers : 396 M
Configured Max Global Buffers : 176 M
Configured Max Memory Limit : 572 M
Physical Memory : 994 M
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 2 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 24
Key buffer free ratio = 80 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 376 K
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 2.29 %
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 1 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_open_cache = 400 tables
Current table_definition_cache = 400 tables
You have a total of 341 tables
You have 341 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 16 M
Of 514 temp tables, 16% were created on disk
Created disk tmp tables ratio seems fine

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

TABLE LOCKING
Current Lock Wait ratio = 0 : 1733
Your table locking seems to be fine
 
Yo he tenido esos problemas exactamente. En CentOS, con Apache 2 prefork y PHP 5 con FastCGI. Y la causa raíz no es MySQL.
 
Yo he tenido esos problemas exactamente. En CentOS, con Apache 2 prefork y PHP 5 con FastCGI. Y la causa raíz no es MySQL.

Y cual seria la raiz entonces o como puedo solucionar el problema?
 
Disminuye el valor de innodb_buffer_pool_size

innodb_buffer_pool_size = 64M

Reinicias y me cuentas.
 
Lo más sencillo que puedes hacer es activar los logs y esperar a que se caiga y luego revisar por que se a caido, normalmene cuando se cae muy seguido y no inicia solo es que te quedas sin ram o bien tiene muchas tablas temporales :/

Según el mysql-primer pinta que consumes mucha ram, aunque marca 128MB y eso en 5 minutos de uptime así que no es muy fiable, deberías dejarlo minimo unas 5 horas online si no se cae antes o 48 que es lo recomendado.

En todo caso, revisa los logs ahĺ encontrarás la solución.
 
hice un nuevo post en wp q eso es lo que siempre lo cuelga, por ahora no se colgo, pero quise tirar un top y..

top
-bash: fork: Cannot allocate memory
 
hice un nuevo post en wp q eso es lo que siempre lo cuelga, por ahora no se colgo, pero quise tirar un top y..

top
-bash: fork: Cannot allocate memory

Te quedas sin RAM :/

Has un upgrade a tu VPS o detecta lo que más consume, la verdad que 1 giga de ram en un KVM es muy poca RAM si tienes todo metido ahí mismo, puede que sea problema de algún plugin.
 
Apache te podría estar consumiendo mucha memoria, o cualquier otro proceso, y no deja funcionar adecuadamente a MySQL.
 
Ahora tire otro top y me dice 300 mb memoria libre..

aca pego el top, puede que apache se coma toda la memoria y eso haga caer a mysql? de ser asi tendria que revisar a apache

top - 16:23:12 up 37 min, 1 user, load average: 1.50, 3.05, 1.55
Tasks: 97 total, 5 running, 92 sleeping, 0 stopped, 0 zombie
Cpu(s): 60.5%us, 7.0%sy, 0.0%ni, 31.9%id, 0.0%wa, 0.0%hi, 0.3%si, 0.3%st
Mem: 1018820k total, 739396k used, 279424k free, 10032k buffers
Swap: 0k total, 0k used, 0k free, 49216k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4403 www-data 20 0 354m 52m 4816 S 21.6 5.3 0:01.51 apache2
4428 www-data 20 0 393m 94m 4804 S 19.3 9.5 0:01.39 apache2
4414 www-data 20 0 365m 66m 3920 R 13.0 6.7 0:00.51 apache2
4405 www-data 20 0 349m 85m 4388 R 6.3 8.6 0:01.59 apache2
4417 www-data 20 0 323m 24m 3512 R 2.3 2.5 0:00.19 apache2
4408 www-data 20 0 383m 83m 4700 S 2.0 8.4 0:00.89 apache2
4419 www-data 20 0 315m 17m 3464 S 2.0 1.7 0:00.17 apache2
3120 mysql 20 0 799m 63m 2756 S 0.7 6.3 0:06.06 mysqld
10 root 20 0 0 0 0 R 0.3 0.0 0:01.30 rcu_sched
4442 root 20 0 17344 1240 916 R 0.3 0.1 0:00.08 top
1 root 20 0 24348 924 0 S 0.0 0.1 0:00.98 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.14 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:0
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/u:0H
8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
11 root RT 0 0 0 0 S 0.0 0.0 0:00.09 watchdog/0
12 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 cpuset
13 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 devfreq_wq
24 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
25 root 20 0 0 0 0 S 0.0 0.0 1:03.29 kswapd0
26 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
27 root 39 19 0 0 0 S 0.0 0.0 0:00.00 khugepaged
28 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
29 root 20 0 0 0 0 S 0.0 0.0 0:00.00 ecryptfs-kthrea
30 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
41 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld
42 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1
43 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
44 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1
46 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 binder
66 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq
67 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 charger_manager
190 root 20 0 0 0 0 S 0.0 0.0 0:00.08 jbd2/vda-8
 
Puedes ajustar Apache (prefork) para que cuando los procesos no se utilizen liberen memoria. Creo que es la directiva "MaxSpareServers".
 
Puedes ajustar Apache (prefork) para que cuando los procesos no se utilizen liberen memoria. Creo que es la directiva "MaxSpareServers".

asi esta ahora
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 100
MaxRequestsPerChild 600

---------- Post agregado el 25-abr-2014 hora: 17:39 ----------

Tenia el keepalive on, lo puse off
 
StartServers 2
MinSpareServers 3
MaxSpareServers 5

No soy un experto en esto, pero he tenido buenos resultados al hacer esto. Solo que no sirve de mucho cuando los visitantes o bots entran a una determinada hora.

---------- Post agregado el 25-abr-2014 hora: 14:02 ----------

Por cierto, un sistema con menos de 2 GB de RAM, se beneficia de un sistema operativo de 32-bits, ya que el de 64 bits consume un poco más de memoria RAM.
 
Muchas gracias! por ahora no se volvio a caer (despues de cambiar el keep alive)

---------- Post agregado el 26-abr-2014 hora: 15:54 ----------

Bueno, hice un post en wp y me volvio a pasar lo mismo... vi que apache consumió bastante memoria hasta que se cayó mysql por completo

---------- Post agregado el 26-abr-2014 hora: 19:28 ----------

Por ahora no volvi a tener problemas pero tengo una duda, no tengo swap, conviene ponerle?
 
Bueno, segui con este problema, peor el dia de hoy tuvo pico de visitas y apache comia toda la memoria y se caia, lo que hice fue aumentar el memory_limit en php.ini, estaba en 128 y lo pase a 256 y no volvio a caer, dejo el dato por si a alguien le sucede, aunque no se si lo que hice esta correcto o no.
 
No es apache el que consume toda esa ram, el problema es de php que lo estas ejecutando como mod_php (si fuera así ya que apache consumiría tantos recursos solo si tuvieras mucho tráfico y muchísimo contenido estático)

Así que tienes que ver que es lo se esta ejecutando php, ( script, plugins etc etc ) y dejar apache en segundo plano por ahora.
 
No es apache el que consume toda esa ram, el problema es de php que lo estas ejecutando como mod_php (si fuera así ya que apache consumiría tantos recursos solo si tuvieras mucho tráfico y muchísimo contenido estático)

Así que tienes que ver que es lo se esta ejecutando php, ( script, plugins etc etc ) y dejar apache en segundo plano por ahora.

No es normal este consumo o puede que si? osea aumente el memory_limit en php.ini y no tuve ningun problema mas.
 
Hola Amigo,

A mi me pasaba lo mismo, aqui esta la solución, resulta que DigitalOcean te da un VPS sin memoria Swap esto hace que cualquier servicio consuma la memoria fisica que tengas, ahora bien si le colocas un poco de memoria swap de seguro no se caera tan facil, yo tengo varias web con wordpress con trafico bajo - mediano con nginx php-fpm redis mysql y todo me funciona bien.

Aqui te dejo varios enlaces
Linux Add a Swap File ? Howto
Setting SWAP Memory under Linux

Saludos.
 
Hola Amigo,

A mi me pasaba lo mismo, aqui esta la solución, resulta que DigitalOcean te da un VPS sin memoria Swap esto hace que cualquier servicio consuma la memoria fisica que tengas, ahora bien si le colocas un poco de memoria swap de seguro no se caera tan facil, yo tengo varias web con wordpress con trafico bajo - mediano con nginx php-fpm redis mysql y todo me funciona bien.

Aqui te dejo varios enlaces
Linux Add a Swap File ? Howto
Setting SWAP Memory under Linux

Saludos.

Hola si, ya le puse 4gb de swap y aun asi se los come tambien
 

Temas similares

Atrás
Arriba