Hola Wecindario, hoy vamos a ver como instalar, y usar el MySQLTuner , empecemos:

MySQLTuner es un script gratuito, fácil de usar y de instalar y de entender, es open source (aquí el repositorio) y muy útil. No modifica nada, pero indica qué podríamos  modificar y  cómo mejorarlo.

Hosting Web

Cómo descargar el MySQLTuner

Con tener internet y ejecutar el wget es suficiente, y lo que vamos a descargar es un archivo Perl que hay en internet y lo descargamos a través de HTTP, y se consigue con  wget exactamente:

wget http://mysqltuner.pl/ -O mysqltuner.pl

Si wget no te funciona wget, simplemente visita la página http://mysqltuner.pl/ (que a la vez te redirige al archivo), copia el código  y lo pones en un archivo con extnesión.pl.

Y necesitas tener perl instalado, pero hoy en día todos los Linux lo llevan

Cómo Ejecutar script de MySQLTuner para la mejora de la instalación del MySQL

Una vez instalado ejecutamos

perl mysqltuner.pl

Importante , Si el archivo  lo has creado tu, y tiene otro nombre, solo cámbialo en el comando anterior, simplemente cámbialo. De ser así te pedirá usuario y contraseña de MySQL

Y ¿que muestra? Un ejemplo de lo que puede mostrar

perl mysqltuner.pl
>> MySQLTuner 1.9.8
* Jean-Marie Renouard <jmrenouard@gmail.com>
* Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.pl/
>> Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 10.3.34-MariaDB-0+deb10u1
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysql/error.log exists
[--] Log file: /var/log/mysql/error.log(98K)
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[OK] Log file /var/log/mysql/error.log is readable.
[!!] /var/log/mysql/error.log contains 674 warning(s).
[OK] /var/log/mysql/error.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql/error.log
[--] 0 shutdown(s) detected in /var/log/mysql/error.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in InnoDB tables: 7.8M (Tables: 258)
[OK] Total fragmented tables: 0

Hosting Web

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Views Metrics -----------------------------------------------------------------------------

-------- Triggers Metrics --------------------------------------------------------------------------

-------- Routines Metrics --------------------------------------------------------------------------

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 13d 1h 2m 27s (384K q [0.341 qps], 31K conn, TX: 266M, RX: 28M)
[--] Reads / Writes: 79% / 21%
[--] Binary logging is disabled
[--] Physical Memory : 1.9G
[--] Max MySQL memory : 28.0G
[--] Other process memory: 0B
[--] Total buffers: 1.4G global + 272.3M per thread (100 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 3.8G (195.11% of installed RAM)
[!!] Maximum possible memory usage: 28.0G (1437.56% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/384K)
[OK] Highest usage of available connections: 9% (9/100)
[OK] Aborted connections: 0.00% (0/31814)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Query cache efficiency: 43.1% (137K cached / 319K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 90% (82K on disk / 91K total)
[OK] Thread cache hit rate: 99% (12 created / 31K connections)
[OK] Table cache hit rate: 99% (158K hits / 159K requests)
[OK] table_definition_cache(2000) is upper than number of tables(419)
[OK] Open file limit used: 0% (84/32K)
[OK] Table locks acquired immediately: 100% (369 immediate / 369 locks)

-------- Performance schema ------------------------------------------------------------------------
[!!] Performance_schema should be activated.
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (93.4M used / 512.0M cache)
[OK] Key buffer size / total MyISAM indexes: 512.0M/129.0K
[OK] Read Key buffer hit rate: 97.6% (905 cached / 22 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 2
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 256.0M/7.8M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (37.5 %): 48.0M * 2/256.0M should be equal to 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 2 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 99.49% (315121 hits/ 316731 total)
[!!] InnoDB Write Log efficiency: 27.31% (1847 hits/ 6763 total)
[OK] InnoDB log waits: 0.00% (0 waits / 8610 writes)

-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/0B
[!!] Aria pagecache hit rate: 90.9% (908K cached / 82K reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Check warning line(s) in /var/log/mysql/error.log file
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Performance schema should be activated for better diagnostics
Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
skip-name-resolve=1
query_cache_size (=0)
query_cache_type (=0)
tmp_table_size (> 512M)
max_heap_table_size (> 32M)
performance_schema=ON
key_buffer_size (~ 97M)
innodb_log_file_size should be (=32M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.


 

¿Y qué es todo esto? ¿cómo lo interpretamos? ¿qué tenemos que mejorar en nuestro Mysql?

Las secciones del reporte de MySQLTuner

Importante: Generalmente lo que pone con OK está bien,  lo que pone con  -- es neutro y  !! es porque algo no anda mal.

1-Storage Engine Statistics

Indica las estadísticas de almacenamiento. Si por ejemplo tenemos algunas tablas fragmentadas, aquí  lo veremos

2-Security Recommendations

La seguridad de nuestra base de datos. Por ejemplo que está bien que no haya usuarios anónimos,o que estén protegidas con contraseña.

3-CVE Security Recommendations

No muestra nada porque no proporcionamos el archivo de las vulnerabilidades de CVE,es para saber  las vulnerabilidades encontradas.

4-Performance Metrics

Aquí muestra la RAM que podría llegar a usar MySQL ; a veces indica cuánto % de toda la memoria está usando.

5-Recommendations

La más interesante de todas , ya que Indica qué cosas deberíamos hacer, así como las variables que se deberiamos ajustar.

En Conclusión

Si eres experto en bases de datos puedes configurar las variables y ajustar las demás cosas que el script te haya recomendado; si estás probando puedes investigar más sobre el ajuste arrojado.

No toques nada, si no lo sabes hacer bien, y haz copia de todo antes de tocarlo

¡Esto es todo , wecindario, si os ha gustado compartir!

Accede a más contenido

En Hoswedaje, te ofrecemos más contenido sobre cómo crear y gestionar una cuenta de correo en Plesk. Por otro lado, también te dejamos cómo configurar un Mail de Mac. Así que te dejamos todo ello y si tienes alguna duda o necesitas ayuda contacta con nosotros.

MySQLTuner  Aprende a cómo crear y gestionar una cuenta en Plesk, leyendo este artículo.

ip publica Si quieres saber y aprender a cómo configurar un Mail de Mac, pincha en este enlace.