MySQL: tuning-primer.sh – настройка производительности сервера MySQL

Автор: | 27/08/2014
 

mysqllogoВ дополнение к скрипту mysqltuner – есть ещё одна возможность проверить текущие настройки MySQL, и получить рекомендации по улучшению его производительности.

Для этого – используем скрипт tuning-primer.sh.

Загружаем его:

# wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh
# chmod +x tuning-primer.sh

Для его работы требуется калькулятор bc, проверяем:

# which bc
which: no bc in (/sbin:/bin:/usr/sbin:/usr/bin)

Устанавливаем, если нету:

 # yum -y install bc
...
Installed:
 bc.x86_64 0:1.06.95-1.el6

Complete!

Запускаем:

# ./tuning-primer.sh

Using login values from ~/.my.cnf
- INITIAL LOGIN ATTEMPT FAILED -
Testing for stored webmin passwords:
None Found
Could not auto detect login info!
Found potential sockets: /var/lib/mysql/mysql.sock
Using: /var/lib/mysql/mysql.sock
Would you like to provide a different socket?: [y/N]
Do you have your login handy ? [y/N] : y
User: root
Password: p@ssw0rd

Would you like me to create a ~/.my.cnf file for you? [y/N] : y

~/.my.cnf already exists!

Replace ? [y/N] : y

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.5.38 i686

Uptime = 0 days 1 hrs 4 min 54 sec
Avg. qps = 0
Total Questions = 17
Threads Connected = 1

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10.000000 sec.
You have 0 out of 38 that take longer than 10.000000 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 1
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 151
Current threads_connected = 1
Historic max_used_connections = 1
The number of used connections is 0% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating

INNODB STATUS
Current InnoDB index space = 0 bytes
Current InnoDB data space = 0 bytes
Current InnoDB buffer pool free = 98 %
Current innodb_buffer_pool_size = 128 M
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 144 M
Configured Max Per-thread Buffers : 122 M
Configured Max Global Buffers : 144 M
Configured Max Memory Limit : 266 M
Physical Memory : 1006 M
Max memory limit seem to be within acceptable norms

KEY BUFFER
No key reads?!
Seriously look into using some indexes
Current MyISAM index space = 105 K
Current key_buffer_size = 16 K
Key cache miss rate is 1 : 0
Key buffer free ratio = 87 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is supported but not enabled
Perhaps you should set the query_cache_size

SORT OPERATIONS
Current sort_buffer_size = 64 K
Current read_rnd_buffer_size = 256 K
No sort operations have been performed
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly

OPEN FILES LIMIT
Current open_files_limit = 1024 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_open_cache = 4 tables
Current table_definition_cache = 400 tables
You have a total of 41 tables
You have 4 open tables.
Current table_cache hit rate is 2%
, while 100% of your table cache is in use
You should probably increase your table_cache

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 16 M
Of 259 temp tables, 12% were created on disk
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 256 K
Current table scan ratio = 4 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 0 : 296
Your table locking seems to be fine

Т.к. информации он выводит много – можно добавить запись в файл.

В конце скрипта, перед блоком:

case $mode in
    all | ALL )

добавляем {, а в конце скрипта:

} | tee tuning-primer.log

Либо – вызывать его сразу с перенаправлением в файл:

# ./tuning-primer.sh &> tuning-primer.log
# head tuning-primer.log

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.1.73 x86_64

Uptime = 21 days 1 hrs 37 min 14 sec
Avg. qps = 0
Total Questions = 253928
Threads Connected = 2