Foros del Web » Administración de Sistemas » Cloud Computing »

Necesito optimizar Apache y Mysql para un VPS

Estas en el tema de Necesito optimizar Apache y Mysql para un VPS en el foro de Cloud Computing en Foros del Web. Hola, actualmente he contratado un VPS de Strato con las siguientes características: CPU GenuineIntel, Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz Parallels Plesk v12 CentOS ...
  #1 (permalink)  
Antiguo 26/11/2014, 07:41
 
Fecha de Ingreso: enero-2014
Mensajes: 22
Antigüedad: 10 años, 3 meses
Puntos: 0
Necesito optimizar Apache y Mysql para un VPS

Hola, actualmente he contratado un VPS de Strato con las siguientes características:

CPU GenuineIntel, Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
Parallels Plesk v12
CentOS 6.6 (Final)
4GB RAM
200GB HDD
Trafico Ilimitado

Cuando la web comienza a tener tráfico comienza a ir muy lento (15..20 usuarios simultaneos). He conseguido mejorar bastante el rendimiento "optimizando" Apache y Mysql con datos que he sacado de internet pero no consigo que funcione correctamente.

Si alguien sabría decirme la configuración adecuada de Apache y Mysql para este VPS o al menos orientarme de qué valores debo ir modificando.. estaría muy agradecido.

Saludos!
  #2 (permalink)  
Antiguo 26/11/2014, 09:31
Avatar de lauser
Moderator Unix/Linux
 
Fecha de Ingreso: julio-2013
Ubicación: Odessa (Ukrania)
Mensajes: 3.278
Antigüedad: 10 años, 8 meses
Puntos: 401
Respuesta: Necesito optimizar Apache y Mysql para un VPS

Has probado a usar MySQLTuner? Creo que te vendría bien.
__________________
Los usuarios que te responden, lo hacen altruistamente y sin ánimo de lucro con el único fin de ayudarte. Se paciente y agradecido.
-SOLOLINUX-
  #3 (permalink)  
Antiguo 26/11/2014, 10:09
 
Fecha de Ingreso: enero-2014
Mensajes: 22
Antigüedad: 10 años, 3 meses
Puntos: 0
Respuesta: Necesito optimizar Apache y Mysql para un VPS

Estos son los resultados del MySQLTunner:


>> MySQLTuner 1.3.0 - Major Hayden <[email protected]>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[OK] Currently running supported MySQL version 5.1.73
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +CSV +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 238K (Tables: 77)
[--] Data in InnoDB tables: 148M (Tables: 543)
[!!] Total fragmented tables: 544

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

-------- Performance Metrics -------------------------------------------------
[--] Up for: 2h 52m 12s (1M q [106.443 qps], 13K conn, TX: 1B, RX: 300M)
[--] Reads / Writes: 99% / 1%
[--] Total buffers: 1.1G global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 1.5G (36% of installed RAM)
[OK] Slow queries: 0% (153/1M)
[OK] Highest usage of available connections: 13% (21/151)
[OK] Key buffer size / total MyISAM indexes: 8.0M/682.0K
[OK] Key buffer hit rate: 100.0% (95M cached / 15 reads)
[!!] Query cache is disabled
[OK] Sorts requiring temporary tables: 0% (2 temp sorts / 222K sorts)
[!!] Joins performed without indexes: 1902
[OK] Temporary tables created on disk: 8% (15K on disk / 178K total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 0% (64 open / 613K opened)
[OK] Open file limit used: 0% (8/1K)
[OK] Table locks acquired immediately: 100% (2M immediate / 2M locks)
[OK] InnoDB buffer pool / data size: 1.0G/148.7M
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Enable the slow query log to troubleshoot bad queries
Adjust your join queries to always utilize indexes
Set thread_cache_size to 4 as a starting value
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
Variables to adjust:
query_cache_size (>= 8M)
join_buffer_size (> 128.0K, or always use indexes with joins)
thread_cache_size (start at 4)
table_open_cache (> 64)
  #4 (permalink)  
Antiguo 26/11/2014, 11:21
Avatar de lauser
Moderator Unix/Linux
 
Fecha de Ingreso: julio-2013
Ubicación: Odessa (Ukrania)
Mensajes: 3.278
Antigüedad: 10 años, 8 meses
Puntos: 401
Respuesta: Necesito optimizar Apache y Mysql para un VPS

Pues aplica las recomendaciones...

Código :
Ver original
  1. nano /etc/mysql/my.cnf

Y si creas un crontab para que roten los logs, mejor que mejor.
__________________
Los usuarios que te responden, lo hacen altruistamente y sin ánimo de lucro con el único fin de ayudarte. Se paciente y agradecido.
-SOLOLINUX-
  #5 (permalink)  
Antiguo 26/11/2014, 11:31
Avatar de lauser
Moderator Unix/Linux
 
Fecha de Ingreso: julio-2013
Ubicación: Odessa (Ukrania)
Mensajes: 3.278
Antigüedad: 10 años, 8 meses
Puntos: 401
Respuesta: Necesito optimizar Apache y Mysql para un VPS

Te pongo un ejemplo:
Código :
Ver original
  1. root@XXXXX:/usr/local/bin# /usr/local/bin/mysqltuner.pl
  2. >>  MySQLTuner 1.3.0 - Major Hayden <[email protected]>
  3. >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
  4. >>  Run with '--help' for additional options and output filtering
  5. Please enter your MySQL administrative login: root
  6. Please enter your MySQL administrative password:
  7. -------- General Statistics --------------------------------------------------
  8. [--] Skipped version check for MySQLTuner script
  9. [OK] Currently running supported MySQL version 5.0.51a-24+lenny2
  10. [!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
  11. -------- Storage Engine Statistics -------------------------------------------
  12. [--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
  13. [--] Data in MyISAM tables: 26M (Tables: 215)
  14. [!!] InnoDB is enabled but isn't being used
  15. [!!] Total fragmented tables: 33
  16. -------- Performance Metrics -------------------------------------------------
  17. [--] Up for: 96d 23h 3m 41s (10M q [1.239 qps], 686K conn, TX: 701M, RX: 1B)
  18. [--] Reads / Writes: 44% / 56%
  19. [--] Total buffers: 58.0M global + 2.6M per thread (100 max threads)
  20. [OK] Maximum possible memory usage: 320.5M (12% of installed RAM)
  21. [OK] Slow queries: 0% (20/10M)
  22. [OK] Highest usage of available connections: 33% (33/100)
  23. [OK] Key buffer size / total MyISAM indexes: 16.0M/8.5M
  24. [OK] Key buffer hit rate: 99.9% (57M cached / 30K reads)
  25. [OK] Query cache efficiency: 78.6% (5M cached / 6M selects)
  26. [!!] Query cache prunes per day: 483
  27. [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 408K sorts)
  28. [!!] Temporary tables created on disk: 36% (269K on disk / 745K total)
  29. [OK] Thread cache hit rate: 99% (427 created / 686K connections)
  30. [!!] Table cache hit rate: 2% (64 open / 3K opened)
  31. [OK] Open file limit used: 11% (120/1K)
  32. [OK] Table locks acquired immediately: 99% (3M immediate / 3M locks)
  33. -------- Recommendations -----------------------------------------------------
  34. General recommendations:
  35. Add skip-innodb to MySQL configuration to disable InnoDB
  36. Run OPTIMIZE TABLE to defragment tables for better performance
  37. Enable the slow query log to troubleshoot bad queries
  38. When making adjustments, make tmp_table_size/max_heap_table_size equal
  39. Reduce your SELECT DISTINCT queries without LIMIT clauses
  40. Increase table_cache gradually to avoid file descriptor limits
  41. Variables to adjust:
  42. query_cache_size (> 16M)
  43. tmp_table_size (> 32M)
  44. max_heap_table_size (> 16M)
  45. table_cache (> 64)

El resultado es:

Código :
Ver original
  1. nano /etc/mysql/my.cnf

Código :
Ver original
  1. [mysqld]
  2. #
  3. # * Basic Settings
  4. #
  5. user            = mysql
  6. pid-file        = /var/run/mysqld/mysqld.pid
  7. socket          = /var/run/mysqld/mysqld.sock
  8. port            = 3306
  9. basedir         = /usr
  10. datadir         = /var/lib/mysql
  11. tmpdir          = /tmp
  12. language        = /usr/share/mysql/english
  13. skip-external-locking
  14. #
  15. # Instead of skip-networking the default is now to listen only on
  16. # localhost which is more compatible and is not less secure.
  17. bind-address            = 127.0.0.1
  18. #
  19. # * Fine Tuning
  20. #
  21. key_buffer              = 16M
  22. max_allowed_packet      = 16M
  23. thread_stack            = 128K
  24. thread_cache_size       = 8
  25. # This replaces the startup script and checks MyISAM tables if needed
  26. # the first time they are touched
  27. myisam-recover          = BACKUP
  28. #max_connections        = 100
  29. table_cache            = 128
  30. #thread_concurrency     = 10
  31. #
  32. # * Query Cache Configuration
  33. #
  34. query_cache_limit       = 1M
  35. query_cache_size        = 32M
  36. tmp_table_sizee        = 64M
  37. max_heap_table_sizee        = 32M
__________________
Los usuarios que te responden, lo hacen altruistamente y sin ánimo de lucro con el único fin de ayudarte. Se paciente y agradecido.
-SOLOLINUX-
  #6 (permalink)  
Antiguo 27/11/2014, 01:51
Avatar de hostigal  
Fecha de Ingreso: junio-2009
Mensajes: 318
Antigüedad: 14 años, 10 meses
Puntos: 6
Respuesta: Necesito optimizar Apache y Mysql para un VPS

tienes activado algun tipo de sistema de cache?
saludos.

Etiquetas: apache, centos, mysql, servidores-dedicados-vps-y-colocación, vps
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:15.