💋

MySQLTunerを実行するワンライナー

2021/08/15に公開

小ネタメモ
https://github.com/major/MySQLTuner-perl

# 実行
$ host="localhost" port="3306" user="root" pass="root"; which git perl >/dev/null && (cd "$(mktemp -d)" && git clone --depth 1 -b master https://github.com/major/MySQLTuner-perl.git . 2>/dev/null && perl mysqltuner.pl --host "$host" --port "$port" --user "$user" --pass "$pass") | tee mysqltuner.log

# カレントにログを吐きます
$ grep -A100 -- "- Recommendations" mysqltuner.log
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    58 CVE(s) found for your MySQL release. Consider upgrading your version !
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce or eliminate persistent connections to reduce connection usage
    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).
    Increase binlog_cache_size (Actual value: 32768)
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
    max_connections (> 151)
    wait_timeout (< 28800)
    interactive_timeout (< 28800)
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    binlog_cache_size (16.0M)
    innodb_buffer_pool_size (>= 155.9M) if possible.
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

そんだけ😌

Discussion