MariaDB에서 mysqltuner를 사용하여 가볍게 튜닝해보기

5 min

language: ja bn de en es fr hi ko pt ru zh-cn zh-tw

안녕하세요, 무능입니다.
시간을 때우기 위해 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는 활성화하고 싶지 않고, 다른 것도 딱히 어려운 것은 없어져서 일단 여기까지 하겠습니다.

그럼 여기까지입니다. 다시 잘 부탁드립니다.

Related Posts