MySQL调优工具是用于分析和优化MySQL数据库性能的软件工具。它们可以帮助识别潜在的性能瓶颈、优化查询性能、调整配置参数以及提高数据库的吞吐量和响应时间。今天分享2个常用的工具。
mysqltuner.pl是一个简单而有效的工具,可以帮助您评估和优化MySQL服务器的配置和性能。它提供有关配置、性能和安全性方面的建议,使您能够针对具体问题做出相应的调整和改进。请注意,mysqltuner.pl是一个独立的第三方工具,使用前请确保阅读并理解其文档和指南。
[root@mysqlserver ~]# perl ./mysqltuner.pl --help
Name:
MySQLTuner 2.2.8 - MySQL High Performance Tuning Script
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) You must provide the remote server's
total memory when connecting to other servers
Connection and Authentication:
--host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306)
--protocol tcp Force TCP connection instead of socket
--user <username> Username to use for authentication
--userenv <envvar> Name of env variable which contAIns username to use for authentication
--pass <password> Password to use for authentication
--passenv <envvar> Name of env variable which contains password to use for authentication
--ssl-ca <path> Path to public key
--mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable
--defaults-file <path> Path to a custom .my.cnf
--defaults-extra-file <path> Path to an extra custom config file
--server-log <path> Path to explicit log file (error_log)
Performance and Reporting Options:
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
--json Print result as JSON string
--prettyjson Print result as JSON formatted string
--skippassword Don't perform checks on user passwords (default: off)
--checkversion Check for updates to MySQLTuner (default: don't check)
--updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)
--forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes
--passwordfile <path> Path to a password file list (one password by line)
--cvefile <path> CVE File for vulnerability checks
--outputfile <path> Path to a output txt file
--reportfile <path> Path to a report txt file
--template <path> Path to a template file
--dumpdir <path> Path to a directory where to dump information files
--feature <feature> Run a specific feature (see FEATURES section)
=head1 OUTPUT OPTIONS
--silent Don't output anything on screen
--verbose Print out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat)
--nocolor Don't print output in color
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
--noinfo Remove informational responses
--debug Print debug information
--noprocess Consider no other process is running
--dbstat Print database information
--nodbstat Don't print database information
--tbstat Print table information
--notbstat Don't print table information
--colstat Print column information
--nocolstat Don't print column information
--idxstat Print index information
--noidxstat Don't print index information
--nomyisamstat Don't print MyIsam information
--sysstat Print system information
--nosysstat Don't print system information
--nostructstat Don't print table structures information
--pfstat Print Performance schema
--nopfstat Don't print Performance schema
--bannedports Ports banned separated by comma (,)
--server-log Define specific error_log to analyze
--maxportallowed Number of open ports allowable on this host
--buffers Print global and per-thread buffer values
上传运行此脚本的linux服务器并赋予执行权限。
chmod 755 mysqltuner.pl
执行分析。
[root@mysqlserver ~]# perl ./mysqltuner.pl --host 192.168.209.128 --port 3307 --user root --pass 'Rootasdf2023##'
tuning-primer.sh是一个方便的工具,可以帮助您评估和优化MySQL服务器的配置和性能。它提供了有关配置、性能和安全性方面的评估和建议,使您能够做出相应的调整和改进。
上传到服务器,并赋予执行权限。
chmod 755 tuning-primer.sh
执行分析。
./tuning-primer.sh
输出结果: