MySQL 8 性能优化工具 - MySQLTuner-perl

1、前言

对于平时不经常使用 MySQL 的人员来说,MySQL 的优化比较难入手,这里推荐 MySQLTuner-perl 工具,简单易用,能够帮助 MySQL 小白解决 80% 的优化问题。

2、MySQLTuner-perl 介绍

MySQLTuner是一个用Perl编写的脚本,允许您快速查看MySQL安装并进行调整以提高性能和稳定性。当前的配置变量和状态数据将被检索并以简短的格式显示沿着还有一些基本的性能建议。

在这个最新版本中,MySQLTuner支持MySQL/MariaDB/Percona Server的~300个指示器。

2.1 MySQLTuner 兼容性

  • MySQL 8.0(部分支持,密码检查不起作用)
  • Percona Server 8.0(部分支持,密码检查不起作用)
  • MySQL 5.7(完全支持)
  • Percona Server 5.7(完全支持)
  • MariaDB 10.3—10.11(完整支持)
  • Galera replication(完全支持)
  • Percona XtraDB集群(完全支持)
  • Mysql Replications(部分支持,无测试环境)
  • MySQL 5.6及更早版本(不支持,弃用版本)
  • Percona Server 5.6(不支持,弃用版本)
  • MariaDB 5.5(不支持,弃用版本)
  • MariaDB 10.2及更早版本(不支持,弃用版本)

2.2 Windows支持部分

  • 支持Windows
  • 在WSL2(Windows子系统Linux)上成功运行MySQLtuner
  • https://docs.microsoft.com/en-us/windows/wsl/

2.3 运行环境要求

  • perl5.6或更高版本(带perl-doc包)
  • 基于Unix/Linux的操作系统(在Linux、BSD变体和Solaris变体上测试)
  • 对MySQL服务器的无限制读取访问(建议MySQL 5.1使用操作系统root访问权限)

3、下载及使用

3.1 下载

# 脚本直接下载(最简单最短的方法)
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv

# 使用git clone
git clone --depth 1 -b master  https://github.com/major/MySQLTuner-perl.git

3.2 使用

cd MySQLTuner-perl
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password

# 输出信息,看最后一部分
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    58 CVE(s) found for your MySQL release. Consider upgrading your version !
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=ON
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time
Variables to adjust:
    skip-name-resolve=ON
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    innodb_buffer_pool_size (>= 4.7G) if possible.
    innodb_redo_log_capacity should be (=32M) if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size.

# 可配置参数
-------- Recommendations ---------------------------------------------------------------------------
Variables to adjust:
    skip-name-resolve=ON
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    innodb_buffer_pool_size (>= 4.7G) if possible.
    innodb_redo_log_capacity should be (=32M) if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size.

# 修改参数,MySQL Ver 8.0.30为例
vim /etc/my.cnf.d/mysql-server.cnf
# 增加, 具体值根据服务器配置
skip-name-resolve=ON
join_buffer_size=16M
innodb_buffer_pool_size=16G
innodb_redo_log_capacity=512M

# 重启MySQL
systemctl restart mysqld.service 

4、参考

官网地址 :https://github.com/major/MySQLTuner-perl

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值