Tuning Primer for Database Server

Tuning Primer Script
This useful script helps dba and sysad tuning up database server. It produces sane recommendations for tuning server variables.

1. The script called Tuning-Primer

Pre-requisite
You need to have a bc package to install it do:

apt-get install bc

How to use it?
1. Simply download the file into one directory of database server Example: /root/mysql-scripts/
2. Change mode to make it executable

chmod 755 tuning-primer.sh

3. Run

/root/mysql-scripts/tuning-primer.sh

4. The script will find the location of the mysql.sock file then ask you then ask you the following:

Using: /var/run/mysqld/mysqld.sock
Would you like to provide a different socket?: [y/N]
Do you have your login handy ? [y/N] :tuning-primer
Would you like me to create a ~/.my.cnf file for you? [y/N] :

5. Preventing that questions to show up you need to create .my.cnf file preferably in root directory with following details only:

nano ~/.my.cnf
[client]
user=root
password=somepassword
socket=/var/run/mysqld/mysqld.sock

5. Results will then shows up same as the following:

[root@db1 mysql-scripts]# /root/mysql-scripts/tuning-primer.sh
 
        -- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -
 
MySQL Version 5.5.15-55-log x86_64
 
Uptime = 0 days 10 hrs 6 min 44 sec
Avg. qps = 900
Total Questions = 32773750
Threads Connected = 7
 
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 enabled.
Current long_query_time = 2.000000 sec.
You have 148854 out of 32773895 that take longer than 2.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 = 32
Current threads_cached = 26
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
 
MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 6
Historic max_used_connections = 101
The number of used connections is 101% of the configured maximum.
You should raise max_connections
 
INNODB STATUS
Current InnoDB index space = 0 bytes
Current InnoDB data space = 0 bytes
Current InnoDB buffer pool free = 97 %
Current innodb_buffer_pool_size = 256 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 : 1.75 G
Configured Max Per-thread Buffers : 1.20 G
Configured Max Global Buffers : 544 M
Configured Max Memory Limit : 1.73 G
Physical Memory : 7.78 G
Max memory limit seem to be within acceptable norms
 
KEY BUFFER
Current MyISAM index space = 1.01 G
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 670
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine
 
QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 13 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 87.04 %
Current query_cache_min_res_unit = 4 K
However, 1959680 queries have been removed from the query cache due to lack of memory
Perhaps you should raise query_cache_size
MySQL won't cache query results that are larger than query_cache_limit in size
 
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 8 M
Sort buffer seems to be fine
 
JOINS
Current join_buffer_size = 132.00 K
You have had 195 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
 
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
 
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 = 128 tables
Current table_definition_cache = 400 tables
You have a total of 445 tables
You have 128 open tables.
Current table_cache hit rate is 0%
, while 100% of your table cache is in use
You should probably increase your table_cache
You should probably increase your table_definition_cache value.
 
TEMP TABLES
Current max_heap_table_size = 32 M
Current tmp_table_size = 16 M
Of 580078 temp tables, 46% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.
 
TABLE SCANS
Current read_buffer_size = 2 M
Current table scan ratio = 100 : 1
read_buffer_size seems to be fine
 
TABLE LOCKING
Current Lock Wait ratio = 1 : 1825
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=ALWAYS'.

NOTES: The proper manual usage should be:

./tuning-primer.sh [ mode ]                 

#Available Modes:                                               #
#       all :           perform all checks (default)            #
#       prompt :        prompt for login credintials and socket #
#                       and execution mode                      #
#       mem, memory :   run checks for tunable options which    #
#                       effect memory usage                     #
#       disk, file :    run checks for options which effect     #
#                       i/o performance or file handle limits   #
#       innodb :        run InnoDB checks /* to be improved */  #
#       misc :          run checks for that don't categorise    #
#                       well Slow Queries, Binary logs,         #
#                       Used Connections and Worker Threads     #

Spread the love

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.