标签:
超爽的mysql性能优化工具---“tuner-primer”
文章来源:http://hi.baidu.com/%CA%AB%D5%B9/blog/item/47e475f04958c8aaa50f5233.htmlmysql下tuner-primer使用说明 mysql tuner-primer是检测mysql的主配置文件my.cnf的有力工具,当然还有其他工具,比如mysqlreport,今天先介绍这个工具的使用。下载并改变执行权限:wget
chmod a+x tuning-primer.sh./tuning-primer.sh首先会要求输入服务器的用户名和密码,并提示保存在当前用户目录下配置文件。再次执行脚本就会运行,不用输入用户名和密码,并给出参数配置,强悍就强悍在这!!!!看看我的相关提示,[root@slave1 tuning-primer]# ./tuning-primer.sh - INITIAL LOGIN ATTEMPT FAILED -Testing Stored for passwords: None Found- RETRY LOGIN ATTEMPT FAILED -Could not auto detect login info!Do you have your login handy ? [y/N] : yUser: rootPassword: Would you like me to create a ~/.my.cnf file for you? [y/N] : y -- MYSQL PERFORMANCE TUNING PRIMER -- - By: Matthew Montgomery -MySQL Version 5.1.22-rc-log i686Uptime = 1 days 2 hrs 16 min 29 secAvg. qps = 348Total Questions = 32946460Threads Connected = 23Warning: Server has not been running for at least 48hrs.It may not be safe to use these recommendationsTo find out more information on how each of theseruntime variables effects performance visit: Visit for info about MySQL's Enterprise Monitoring and Advisory ServiceSLOW QUERIESThe slow query log is NOT enabled.Current long_query_time = 10.000000 sec.You have 44 out of 32946564 that take longer than 10.000000 sec. to completeYour long_query_time seems to be fineBINARY UPDATE LOGThe binary update log is enabledThe expire_logs_days is not set.The mysqld will retain the entire binary log until RESET MASTER or PURGE MASTER LOGS commands are run manuallySetting expire_log_days will allow you to remove old binary logs automaticallySee WORKER THREADSCurrent thread_cache_size = 1024Current threads_cached = 363Current threads_per_sec = 0Historic threads_per_sec = 0Your thread_cache_size is fineMAX CONNECTIONSCurrent max_connections = 1500Current threads_connected = 22Historic max_used_connections = 391The number of used connections is 26% of the configured maximum.Your max_connections variable seems to be fine.MEMORY USAGEMax Memory Ever Allocated : 61 GConfigured Max Per-thread Buffers : 225 GConfigured Max Global Buffers : 2 GConfigured Max Memory Limit : 228 GPhysical Memory : 3.95 GMax memory limit exceeds 90% of physical memoryKEY BUFFERCurrent MyISAM index space = 2 GCurrent key_buffer_size = 512 MKey cache miss rate is 1 : 121Key buffer fill ratio = 31.00 %Your key_buffer_size seems to be too high.Perhaps you can use these resources elsewhereQUERY CACHEQuery cache is enabledCurrent query_cache_size = 64 MCurrent query_cache_used = 14 MCurrent query_cache_limit = 2 MCurrent Query cache Memory fill ratio = 23.29 %Current query_cache_min_res_unit = 4 KQuery Cache is 23 % fragmentedRun "FLUSH QUERY CACHE" periodically to defragment the query cache memoryIf you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.Your query_cache_size seems to be too high.Perhaps you can use these resources elsewhereMySQL won't cache query results that are larger than query_cache_limit in sizeSORT OPERATIONSCurrent sort_buffer_size = 4 MCurrent read_rnd_buffer_size = 15 MSort buffer seems to be fineJOINSCurrent join_buffer_size = 4.00 MYou have had 22509 queries where a join could not use an index properlyjoin_buffer_size >= 4 MThis is not advisedYou should enable "log-queries-not-using-indexes"Then look for non indexed joins in the slow query log.OPEN FILES LIMITCurrent open_files_limit = 8192 filesThe open_files_limit should typically be set to at least 2x-3xthat of table_cache if you have heavy MyISAM usage.Your open_files_limit value seems to be fineTABLE CACHECurrent table_open_cache = 2048 tablesCurrent table_definition_cache = 128 tablesYou have a total of 400 tablesYou have 588 open tables.The table_cache value seems to be fineYou should probably increase your table_definition_cache value.TEMP TABLESCurrent max_heap_table_size = 16 MCurrent tmp_table_size = 64 MOf 53670 temp tables, 44% were created on diskEffective in-memory tmp_table_size is limited to max_heap_table_size.Perhaps you should increase your tmp_table_size and/or max_heap_table_sizeto reduce the number of disk-based temporary tablesNote! 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 SCANSCurrent read_buffer_size = 127 MCurrent table scan ratio = 407 : 1read_buffer_size is over 8 MB there is probably no need for such a large read_bufferTABLE LOCKINGCurrent Lock Wait ratio = 1 : 3135582Your table locking seems to be fineok,通过终端输入,可以显示出各种不通颜色的提示信息,非常人性化,对照参数提示,可以很简单的调整出最适合你的运行环境的配置文件,好了,不多说了,动手吧!!