mysqltunerをつかってmariadbをチューニングしてみた。

VPSサーバをリプレースしたのでmysqltunerをつかってmariadbをチューニングしたのでメモ。

epelからyumでinstallできます。
バージョンは古いですが管理が楽なので気にしません。

# yum install mysqltuner

実行は簡単
↓の様に叩いてユーザーとパスをいれます。

# mysqltuner –buffers

ずらずらーっと出てきますがチューニングした方がいいよって
指摘は一番最後のRecommendationsって所にこんな感じで出力されます。

——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Set thread_cache_size to 4 as a starting value
Variables to adjust:
query_cache_size (>= 8M)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
thread_cache_size (start at 4)

以下の様に出てるのでテーブルリペアをかけます。

Run OPTIMIZE TABLE to defragment tables for better performance

# mysqlcheck -u root -p –auto-repair –optimize –all-databases

Variables to adjust:の項目で指摘された項目をmy.cnfに当て込みます。
自分の環境では以下で落ち着きました。

# vim /etc/my.cnf

[mysqld]
query_cache_size = 8M
tmp_table_size = 16M
max_heap_table_size = 16M
thread_cache_size = 4
query_cache_limit = 2M

チューニングを施してDB再起動をしてると最終的に以下のメッセージになりました。

——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours – recommendations may be inaccurate
Reduce or eliminate unclosed connections and network issues
Variables to adjust:
query_cache_limit (> 4M, or use smaller result sets)

以下のメッセージはmariadb起動から時間がたってないので正確じゃーないよって
いってます、訳せばそのまんま

MySQL started within last 24 hours – recommendations may be inaccurate

query_cache_limitについては、アクセス状況とかサーバーの負荷と相談なので様子見ですね。
とりあえず環境が改善されるといいですね。

タグ , . ブックマークする パーマリンク.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です