elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  Bases de Datos (Moderador: Carloswaldo)
| | | |-+  Herramientas para Optimizar MySQL
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Herramientas para Optimizar MySQL  (Leído 24,960 veces)
el-brujo
ehn
***
Desconectado Desconectado

Mensajes: 21.580


La libertad no se suplica, se conquista


Ver Perfil WWW
Herramientas para Optimizar MySQL
« en: 28 Mayo 2008, 17:32 pm »

Herramientas:

MySQL Tuning Primer

MySQLTuner

mysqlreport

Optimizar MySQL
http://wiki.elhacker.net/bases-de-datos/mysql/optimizacion




MySQL Tuning Primer

Descargar el shell script:
http://www.day32.com/MySQL/tuning-primer.sh

chmod 755 y ejecutar


Citar
[root@ns58 ~]# ./tuning-primer.sh

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

MySQL Version 5.1.52-log i686

Uptime = 7 days 18 hrs 23 min 56 sec
Avg. qps = 100
Total Questions = 67734325
Threads Connected = 157

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.1/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 enabled.
Current long_query_time = 3.000000 sec.
You have 1158 out of 67734355 that take longer than 3.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 http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html

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

MAX CONNECTIONS
Current max_connections = 600
Current threads_connected = 156
Historic max_used_connections = 289
The number of used connections is 48% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 75 M
Current InnoDB data space = 147 M
Current InnoDB buffer pool free = 30 %
Current innodb_buffer_pool_size = 250 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 : 4.42 G
Configured Max Per-thread Buffers : 7.21 G
Configured Max Global Buffers : 978 M
Configured Max Memory Limit : 4.16 G
Physical Memory : 5.21 G

KEY BUFFER
Current MyISAM index space = 416 M
Current key_buffer_size = 600 M
Key cache miss rate is 1 : 6013
Key buffer free ratio = 38 %
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 = 100 M
Current query_cache_used = 31 M
Current query_cache_limit = 20 M
Current Query cache Memory fill ratio = 31.97 %
Current query_cache_min_res_unit = 4 K
Query Cache is 32 % fragmented
Run "FLUSH QUERY CACHE" periodically to defragment the query cache memory
If you have many small queries lower 'query_cache_min_res_unit' to reduce fragme                                 ntation.
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 = 8 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 1433 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 = 3000 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 = 512 tables
Current table_definition_cache = 256 tables
You have a total of 72 tables
You have 427 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 64 M
Current tmp_table_size = 64 M
Of 131907 temp tables, 29% were created on disk
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 = 2 M
Current table scan ratio = 84 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 1407
You may benefit from selective use of InnoDB.





MySQLTuner


Citar
MySQLTuner is a high-performance MySQL tuning script written in perl that will provide you with a snapshot of a MySQL server’s health. Based on the statistics gathered, specific recommendations will be provided that will increase a MySQL server’s efficiency and performance. The script gives you automated MySQL tuning that is on the level of what you would receive from a MySQL DBA.

Perl Script
http://mysqltuner.com/mysqltuner.pl



Features:

    * Memory Usage: Calculates MySQL memory usage at max load and makes recommendations for increasing or decreasing the MySQL memory footprint. Per-thread and server-wide buffer data is calculated separately for an accurate snapshot of the server’s configuration.
    * Slow Queries: Reviews the amount of slow queries relative to the total queries. Slow query time limits are also analyzed and recommendations are made.
    * Connections: Current and historical connection counts are reviewed.
    * Key Buffer: Takes configuration data and compares it to the actual indexes found in MyISAM tables. Key cache hit rates are calculated and variable adjustments are suggested.
    * Query Cache: Query cache hit rates and usage percentages are used to make recommendations for the query cache configuration variables.
    * Sorting & Joins: Per-thread buffers that affect sorts and joins are reviewed along with the statistics from the queries run against the server.
    * Temporary Tables: Variable recommendations are made to reduce temporary tables that are written to the disk.
    * Table Cache: Compares total tables opened to the currently open tables. Calculates the table cache hit rate in order to make suggestions.
    * Open Files: Determines if the server will approach or run into the open file limit set by the operating system or the MySQL server itself.
    * Table Locks: Finds table locking that forces queries to wait and makes suggestions for reducing locks that require a wait.
    * Thread Cache: Calculates how many times MySQL must create a new thread to respond to a query.
    * Aborted Connections: Finds applications that are not closing connections to MySQL properly.
    * Read/Write Ratios: Calculates the percentage of read and write operations on your MySQL installation.

Usage:

# ./mysqltuner.pl --help

   MySQLTuner 0.9.0 - MySQL High Performance Tuning Script
   Bug reports, feature requests, and downloads at http://mysqltuner.com/
   Maintained by Major Hayden (major@mhtx.net)

   Important Usage Guidelines:
      To run the script with the default options, run the script without arguments
      Allow MySQL server to run for at least 24-48 hours before trusting suggestions
      Some routines may require root level privileges (script will provide warnings)

   Performance and Reporting Options
      --skipsize       Don't enumerate tables and their types/sizes
                       (Recommended for servers with many tables)
      --skipversion    Don't check for updates to MySQLTuner

   Output Options:
      --nogood         Remove OK responses
      --nobad          Remove negative/suggestion responses
      --noinfo         Remove informational responses
      --nocolor        Don't print output in color

Here is a sample of the script’s output on a well optimized server:

 >>  MySQLTuner 0.9.0 - Major Hayden
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with ‘–help’ for additional options and output filtering

——– General Statistics ————————————————–
[OK] You have the latest version of MySQLTuner
[OK] Currently running supported MySQL version 5.0.51a-log
[OK] Operating on 64-bit architecture

——– Storage Engine Statistics ——————————————-
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 491M (Tables: 1424)
[--] Data in InnoDB tables: 9M (Tables: 151)

——– Performance Metrics ————————————————-
[--] Up for: 19d 16h 14m 3s (57M q [33.636 qps], 5M conn, TX: 185B, RX: 5B)
[--] Reads / Writes: 77% / 23%
[--] Total buffers: 2.7M per thread and 606.0M global
[OK] Maximum possible memory usage: 743.5M (37% of installed RAM)
[OK] Slow queries: 0% (81/57M)
[!!] Highest connection usage: 100%  (51/50)
[OK] Key buffer size / total MyISAM indexes: 256.0M/210.9M
[OK] Key buffer hit rate: 99.3%
[OK] Query cache efficiency: 71.4%
[!!] Query cache prunes per day: 2752
[OK] Sorts requiring temporary tables: 0%
[OK] Temporary tables created on disk: 2%
[OK] Thread cache hit rate: 99%
[!!] Table cache hit rate: 2%
[OK] Open file limit used: 4%
[OK] Table locks acquired immediately: 99%
[OK] InnoDB data size / buffer pool: 9.8M/50.0M

——– Recommendations —————————————————–
General recommendations:
    Reduce or eliminate persistent connections to reduce connection usage
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    max_connections (> 50)
    wait_timeout (< 15)
    interactive_timeout (< 15)
    query_cache_size (> 256M)
    table_cache (> 4096)




mysqlreport


Citar
mysqlreport makes a friendly report of important MySQL status values. mysqlreport transforms the values from SHOW STATUS into an easy-to-read report that provides an in-depth understanding of how well MySQL is running. mysqlreport is a better alternative (and practically the only alternative) to manually interpreting SHOW STATUS.

Descargar Perl Script
http://hackmysql.com/scripts/mysqlreport

http://tag1consulting.com/MySQL_Monitoring_and_Tuning



Código
  1. #!/bin/bash
  2. # Written by James Crow crow.jamesm <at> google email domain name <dot> com
  3. # 2010-09-16
  4. # This script connects to the MythTV mythconverg database to pull
  5. # the two most important tuning parameters. This script only works
  6. # for MyISAM tables at the moment. The only part that needs to be
  7. # configured is the variables at the top of the script
  8. # ver 0.1
  9.  
  10. # *** Change these to match you environment ***
  11. mysql='/usr/bin/mysql'
  12. mythconverg='mythconverg'
  13. sql_user='mythtv'
  14. sql_pass='mythtv'
  15. sql_host='192.168.1.2'
  16. # *** You should not need to change anything after this line ***
  17.  
  18. # determine if we are using MyISAM tables
  19. $mysql -h $sql_host -u $sql_user -p$sql_pass $mythconverg -e 'show
  20. create table record' | grep -q MyISAM
  21. myisam=$?
  22.  
  23. if [ $myisam -ne 0 ]; then
  24. echo "You do not appear to be using MyISAM tables for the myth database"
  25. exit;
  26. fi
  27. #echo $myisam
  28.  
  29. # The most important tuning parameters are the key_buffer_size and
  30. table_open_cache
  31. # find the key_buffer_size and % in use first
  32. key_blocks_unused=`$mysql -h $sql_host -u $sql_user -p$sql_pass -e
  33. 'show status like "key_blocks_unused"' | grep "[Kk]ey_blocks_unused" |
  34. sed 's/[^0-9]//g'`
  35. key_cache_block_size=`$mysql -h $sql_host -u $sql_user -p$sql_pass -e
  36. 'show variables like "key_cache_block_size"' | grep
  37. key_cache_block_size | sed 's/[^0-9]//g'`
  38. key_buffer_size=`$mysql -h $sql_host -u $sql_user -p$sql_pass -e 'show
  39. variables like "key_buffer_size"' | grep key_buffer_size | sed
  40. 's/[^0-9]//g'`
  41.  
  42. # using a simple formula from the MySQL doc we get the key_buffer_cache in use
  43. key_buffer_cache_in_use=`echo "scale=2; 1-(($key_blocks_unused *
  44. $key_cache_block_size)/$key_buffer_size)" | bc`
  45. # this next line rounds each value to an even integer, but that is the
  46. best way to display the result
  47. key_buffer_use_pct=`echo "scale=0; $key_buffer_cache_in_use*100" | bc`
  48. key_buffer_use_pct=`echo "($key_buffer_use_pct+0.5)/1" | bc`
  49. #echo "scale=0; $key_buffer_cache_in_use*100"
  50. echo ""
  51. echo "**** key_buffer_cache section *****************************"
  52. if [ $key_buffer_use_pct -eq 100 ]; then
  53. echo "!!!!!! WARNING: You are using 100% of your key_buffer_cache."
  54. echo "                You should raise the value!"
  55. elif [ $key_buffer_use_pct -gt 80 ]; then
  56. echo "NOTE: You are using more than 80% of your key_buffer_cache."
  57. echo "      You may may want to raise the value."
  58. fi
  59. echo "key_buffer_size: $key_buffer_size, $(($key_buffer_size/1024))
  60. kb, $(($key_buffer_size/(1024*1024))) mb"
  61. echo "key_buffer_cache in use: $key_buffer_use_pct%"
  62. echo "***********************************************************"
  63.  
  64. # the second of two most important variables is the table_open_cache
  65. open_tables=`$mysql -h $sql_host -u $sql_user -p$sql_pass -e 'show
  66. status like "open_tables"' | grep Open_tables | sed 's/[^0-9]//g'`
  67. open_table_cache=`$mysql -h $sql_host -u $sql_user -p$sql_pass -e
  68. 'show variables like "table_open_cache"' | grep table_open_cache | sed
  69. 's/[^0-9]//g'`
  70. free_tables=$(($open_table_cache-$open_tables))
  71. open_tables_free_pct=`echo "scale=2; $free_tables/$open_table_cache*100" | bc`
  72. open_tables_free_pct=`echo "($open_tables_free_pct+0.5)/1" | bc`
  73. #echo "scale=0; $free_tables/$open_table_cache*100"
  74. echo ""
  75. echo "**** table_open_cache section *****************************"
  76. if [ $free_tables -eq 0 ]; then
  77. echo "!!!!!! WARNING: You have no free tables."
  78. echo "                You should raise the value."
  79. elif [ $open_tables_free_pct -lt 10 ]; then
  80. echo "NOTE: You have less than 10% free in the table_open_cache."
  81. echo "      You may want to raise the value."
  82. fi
  83. echo "table_open_cache: $free_tables free out of $open_table_cache,
  84. $open_tables used"
  85. echo "table_open_cache used pct: $((100-$open_tables_free_pct))%"
  86. echo "***********************************************************"


« Última modificación: 3 Abril 2012, 10:59 am por el-brujo » En línea

Rojodos
Colaborador
***
Desconectado Desconectado

Mensajes: 3.536



Ver Perfil WWW
Re: Herramientas para Optimizar MySQL
« Respuesta #1 en: 2 Agosto 2011, 19:19 pm »

Interesante, tengo varios servidores con CRMs y MySQLs que me estan dando problemas....


En línea

folostia

Desconectado Desconectado

Mensajes: 111


Ver Perfil
Re: Herramientas para Optimizar MySQL
« Respuesta #2 en: 23 Octubre 2011, 14:22 pm »

muy bueno,gracias por el aporte  ;)
En línea

"Antes de que un software pueda ser reusable, primero ha de ser usable." (Ralph Johnson)
Usuario Linux:547941
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[?] MySQL "Registros Faltantes" Optimizar Consulta
Bases de Datos
AlbertoBSD 4 10,442 Último mensaje 19 Abril 2009, 08:06 am
por -explicito-
Optimizar Disco Duro (HD) para MySQL
Bases de Datos
Skeletron 4 7,620 Último mensaje 25 Febrero 2010, 14:38 pm
por Skeletron
Programas para optimizar windows « 1 2 »
Windows
crazykenny 10 8,254 Último mensaje 13 Julio 2010, 23:38 pm
por Randomize
Recomendaciones para Optimizar INDEX
Bases de Datos
Skeletron 0 2,014 Último mensaje 11 Enero 2011, 01:50 am
por Skeletron
[MySQL] Optimizar Conexiones mediante PHP ?
PHP
Diabliyo 2 3,810 Último mensaje 11 Febrero 2012, 00:26 am
por дٳŦ٭
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines