mysql服务器性能调优工具

  数据库服务器的性能在网络服务中往往起着至关重要的作用,通常首先会考虑优化sql语句,因为sql语句的优劣对响应时间有着直接的关系,然而有时候当sql已经优化到极限还达不到理想要求时,可以考虑优化数据库服务器的参数,已达到一个最好的状态。
  但是服务器参数有许多个,会导致无从着手,如果一个个调查研究过来,难免有些盲目低效。以下将结合一个工具(tuning-primer.sh),介绍一下如何对mysql数据库服务器进行参数调优。

  推荐方法概要:通过使用tuning-primer.sh工具,得到服务器当前状态和推荐设置方法,结合实际应用情况进行参数调整。

  方法详细:

  1.下载tuning-primer.sh:http://www.day32.com/MySQL/tuning-primer.sh
  2.拷贝到数据库服务器所在的机器上(linux环境)
  3.执行: ./tuning-primer.sh
  4.得到执行结果:(见文章结尾英文部分)
  5.结合实际应用调整相应的参数值   

执行结果:

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

MySQL Version 5.1.28-rc-community i686

Uptime = 0 days 7 hrs 8 min 1 sec
Avg. qps = 0
Total Questions = 581
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.1/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 602 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.1/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 = 2
The number of used connections is 1% 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

MEMORY USAGE
Max Memory Ever Allocated : 23 M
Configured Max Per-thread Buffers : 405 M
Configured Max Global Buffers : 17 M
Configured Max Memory Limit : 423 M
Physical Memory : 1.44 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
No key reads?!
Seriously look into using some indexes
Current MyISAM index space = 98 K
Current key_buffer_size = 7 M
Key cache miss rate is 1 : 0
Key buffer free ratio = 88 %
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 = 2 M
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 = 64 tables
Current table_definition_cache = 256 tables
You have a total of 23 tables
You have 23 open tables.
The table_cache value seems to be fine

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

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 2 : 1
read_buffer_size seems to be fine

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

猜你喜欢

转载自like-eagle.iteye.com/blog/1316412
今日推荐