설치

MySQLTuner-perl 는 MySQL 이나 MariaDB 의 설치 및 설정을 빠르게 리뷰해주고 최적화를 위한 옵션을 제안해주는 Perl 로 작성한 스크립트입니다.

최적화된 MySQL 설정 파일을 만들어 주는 Percona Tools for MySQL 이 유료화되면서 경험많은 DBA 가 없을 경우 간단하게 쓸 수 있는 도구입니다.


설치하려면 실행 스크립트를 다운받으면 됩니다.

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
BASH


잘 모르는 항목인데 metadata 통계 필드를 update 하는 건 MySQL 서버와 mysqltuner 성능에 엄청난 악영향을 준다고 하니 켜져 있으면 꺼줍니다.

set global innodb_stats_on_metadata = 0;
BASH


실행

perl 로 작성된 스크립트이므로 다음 명령어로 실행하면 현재 시스템을 진단하고 제안을 출력해 줍니다.

perl mysqltuner.pl
BASH


시작시 root 계정과 암호를 물어보는 데 커맨드 라인에서 전달하려면 --user 와 --pass 옵션을 사용합니다.

perl mysqltuner.pl --user root --pass my_root_pwd
CODE


현재 설정을 분석하고 내용을 출력한 후에 Recommendations 에 권고 사항을 출력해 줍니다.

...
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
 
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server
 
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Reduce or eliminate unclosed connections and network issues
    Performance schema should be activated for better diagnostics
    Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
    Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    performance_schema = ON enable PFS
BASH


이런 도구들이 다 그렇지만 진단 내용에 대한 이해가 선행되어야 제대로 결과를 활용할 수 있습니다.

그리고 MariaDB 설치후 바로 실행하는 것은 성능 진단에 별 도움이 안되며 어느 정도 운영해서 데이터가 쌓여야 의미있는 결과가 나온다고 저자는 얘기하고 있습니다.


memory checks

  • Get total RAM/swap
  • Is there enough memory for max connections reached by MySQL ?
  • Is there enough memory for max connections allowed by MySQL ?
  • Max percentage of memory used(<85%)

InnoDB Information

InnoDB 일 경우 다음과 같은 항목들을 검사합니다.

  • InnoDB Buffer Pool Size
  • InnoDB Buffer Pool Usage
  • InnoDB Buffer Pool Log Size
  • InnoDB Read efficiency
  • InnoDB Write efficiency
  • InnoDB Log Waits
  • InnoDB Chunk Size

Ref