26
Июл

mysqltuner и mytop на Centos 6.8

Оптимизация настроек MySQL с помощью Mysqltuner

Mysqltuner — это perl-скрипт, который анализирует статистику работы Mysql и выдает свои рекомендации по оптимизации настроек Mysql сервера.

Скачать скрипт можно следующим образом:

# wget <a class="external free" href="https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl" rel="nofollow">https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl</a>

Если возникает ошибка вида:

 ERROR: cannot verify raw.githubusercontent.com's certificate, issued by '/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA':
 Unable to locally verify the issuer's authority.
 To connect to raw.githubusercontent.com insecurely, use `--no-check-certificate'.

Запускаем с ключом —no-check-certificate:

# wget <a class="external free" href="https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl" rel="nofollow">https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl</a> --no-check-certificate

Также, можно произвести установку:

Debian/Ubuntu:

# apt-get -y install mysqltuner

CentOS:

# yum -y install mysqltuner

Чтобы данные анализа и статистика были более корректными, сервер Mysql должен проработать некоторое время без смены параметров конфигурации и без перезагрузок, по рекомендации самого Mysqltuner не менее 24 часов.

Теперь можно запускать Mysqltuner.

Если производилось скачивание скрипта:

# perl mysqltuner.pl

или

# perl mysqltuner.pl --user root --pass rootpassword

Если производилась установка:

#  mysqltuner

или

#  mysqltuner --user root --pass rootpassword

После запуска скрипт произведет анализ и выдаст следующую информацию:

# perl mysqltuner.pl --user root --pass rootpassword
&gt;&gt;  MySQLTuner 1.2.0 - Major Hayden &lt;[email protected]&gt;
&gt;&gt;  Bug reports, feature requests, and downloads at <a class="external free" href="http://mysqltuner.com/" rel="nofollow">http://mysqltuner.com/</a>
&gt;&gt;  Run with '--help' for additional options and output filtering
[OK] Logged in using credentials passed on the command line
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.33
[OK] Operating on 32-bit architecture with less than 2GB RAM
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] InnoDB is enabled but isn't being used
[OK] Total fragmented tables: 0
-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 20h 45m 49s (101 q [0.001 qps], 7 conn, TX: 28K, RX: 3K)
[--] Reads / Writes: 100% / 0%
[--] Total buffers: 160.0M global + 832.0K per thread (151 max threads)
[OK] Maximum possible memory usage: 282.7M (55% of installed RAM)
[OK] Slow queries: 0% (0/101)
[OK] Highest usage of available connections: 1% (2/151)
[!!] Key buffer size / total MyISAM indexes: 16.0K/679.0K
[!!] Query cache is disabled
[OK] Temporary tables created on disk: 3% (3 on disk / 94 total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 11% (4 open / 35 opened)
[OK] Open file limit used: 0% (6/7K)
[OK] Table locks acquired immediately: 100% (37 immediate / 37 locks)
[!!] Connections aborted: 14%
-------- Recommendations -----------------------------------------------------
General recommendations:
   Add skip-innodb to MySQL configuration to disable InnoDB
   MySQL started within last 24 hours - recommendations may be inaccurate
   Enable the slow query log to troubleshoot bad queries
   Set thread_cache_size to 4 as a starting value
   Increase table_cache gradually to avoid file descriptor limits
   Your applications are not closing MySQL connections properly
Variables to adjust:
   key_buffer_size (&gt; 679.0K)
   query_cache_size (&gt;= 8M)
   thread_cache_size (start at 4)
   table_cache (&gt; 4)

Особое внимание стоит уделить строкам, помеченным символами [!!] и секции Recommendations.

Параметры указанные после строки Variables to adjust нужно изменить в файле my.cnf, в соответствии с рекомендациями Mysqltuner. Если указанного параметра нет в файле my.cnf, то его следует дописать.

Расположение конфигурационного файла my.cnf:

Debian/Ubuntu:

/etc/mysql/my.cnf

CentOS:

/etc/my.cnf

После внесения изменений в файл my.cnf нужно перезагрузить Mysql-сервер:

Debian/Ubuntu:

# /etc/init.d/mysql restart

CentOS 6:

# /etc/init.d/mysqld restart

Centos 7

# sysyemctl restart mariadb

После изменения конфигурации Mysql-сервер должен проработать минимум 24 часа без перезагрузок. Затем, можно снова запустить утилиту Mysqltuner и проанализировать вывод статистики. Таким образом, можно привести конфигурационный файл my.cnf и работу Mysql-сервера, соответственно, к оптимальному состоянию.

Установка mytop на Centos 6.8

<span class="crayon-p">yum install mytop</span>

Настроить mytop можно 3 способами:

1.Запуск с передачей аргументов с командной строки

mytop -u root -p123456789 -d mysql_base --prompt

2.Создание файла .mytop в домашнем каталоге пользователя(например,root)

<span class="crayon-p">nano /root/.mytop</span>
user=root
pass=123456789
delay=1
db=mysql[/bash]
<span class="crayon-p">chmod 400 /root/.mytop &amp;&amp; chown root:root /root/.mytop

</span>

и запускаем просто через команду mytop

3.Редактирование бинарника

<span class="crayon-p"> which mytop </span>
/usr/bin/mytop[/bash]
nano /usr/bin/mytop[/bash]

user=root
pass=123456789
delay=1
db=mysql[/bash]

Обратная связь

    The average number of adverse effects was 3. T max is 23 minutes in females and 32 minutes in males. What other drugs will affect doxercalciferol Viagra natural sin receta. Archived from the original on 2009-08-14.

    Talk to your doctor before using this form of cefadroxil if you have diabetes. What should I tell my healthcare team before starting CABLIVI? There is no FDA guidance on the use of Tetracycline (oral) with respect to specific gender populations https://www.apotheke-rezeptfreie.com/. Opper K, Uder S, Song K Development of Heterogeneous and Homogeneous Platforms for Rapid Analysis of DNA-Protein Interactions.