MariaDBでmysqltunerを使って軽くチューニングしてみる
3 min read
こんにちは、無能です。
暇つぶしに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
は有効にしたくないし、他も別に厳しそうなものは無くなったので一旦ここまでにしよう。
それではここまで。またよろしくおねがいします。