Легкая настройка MariaDB с помощью mysqltuner
Здравствуйте, я некомпетентен.
В поисках чего-нибудь, что можно было бы настроить в MariaDB для времяпровождения, я нашел и установил программу для тюнинга MySQL под названием mysqltuner.
Установка
В 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.
※Это может быть ловушкой: если вы используете user@localhost в MariaDB, возможно, лучше этого не делать. : 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, и других серьезных проблем не осталось, так что на этом пока остановимся.
На этом все. До новых встреч.