尝试使用mysqltuner对MariaDB进行简单调优
大家好,我是无能。
闲来无事,我在MariaDB中寻找一些可以折腾的东西,结果发现了一个名为mysqltuner的MySQL调优软件,于是就安装了。
安装
在Devuan上,使用以下命令安装。
sudo apt install mysqltuner
执行
它以这种交互式的方式开始。
$ mysqltuner
>> MySQLTuner 1.9.9
* 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
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:
最后显示了这样的内容。
General recommendations:
You are using n unsupported version for production environments
Upgrade as soon as possible to a supported version !
Reduce or eliminate unclosed connections and network issues
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
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).
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
skip-name-resolve=1
join_buffer_size (> 256.0K, or always use indexes with JOINs)
table_definition_cache(400) > 585 or -1 (autosizing if supported)
performance_schema=ON
innodb_buffer_pool_size (>= 1.3G) if possible.
innodb_log_file_size should be (=32M) if possible, so InnoDB total log files size equals 25% of buffer pool size.
DNS名称解析似乎最好跳过。
※这似乎是一个陷阱,如果在MariaDB中使用user@localhost,最好不要这样做: 写入skip-name-resolve时无法连接到DB的情况 – netcreates. blog
因此,我使用grep -r mysqld查找目标部分的conf文件,发现路径是/etc/mysql/mariadb.conf.d/50-server.cnf ,于是就添加了。
然后,join_buffer_size的尺寸似乎最好调整一下,所以我也改了。
表定义的缓存似乎也最好设置一下,所以我也改了。
innodb的日志文件大小似乎也最好指定一下,以防止其过度膨胀。
我还指定了innodb的缓冲池大小,但设置得相当小。
[mysqld]
skip-name-resolve=1
join_buffer_size = 512K
table_definition_cache = 600
innodb_log_file_size = 32M
innodb_buffer_pool_size = 2G
如果语法中已经有注释,则取消注释,然后应用上述设置并重启MariaDB。
sudo service mariadb restart
然后,再次运行mysqltuner的结果。
General recommendations:
You are using n unsupported version for production environments
Upgrade as soon as possible to a supported version !
MySQL was started within the last 24 hours - recommendations may be inaccurate
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).
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
join_buffer_size (> 512.0K, or always use indexes with JOINs)
performance_schema=ON
innodb_log_file_size should be (=512M) if possible, so InnoDB total log files size equals 25% of buffer pool size.
我不想启用performance_schema,而且也没有其他特别严格的建议了,所以暂时就到这里吧。
那么就到这里。下次再见。