{"id":505,"date":"2008-06-21T00:00:00","date_gmt":"2008-06-20T16:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=505"},"modified":"2011-07-15T09:30:03","modified_gmt":"2011-07-15T01:30:03","slug":"mysql-tuner-primer","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=505","title":{"rendered":"mysql tuner-primer"},"content":{"rendered":"<p><DIV>mysql\u4e0btuner-primer\u4f7f\u7528\u8bf4\u660e <BR>mysql tuner-primer\u662f\u68c0\u6d4bmysql\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6my.cnf\u7684\u6709\u529b\u5de5\u5177\uff0c\u5f53\u7136\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\uff0c\u6bd4\u5982mysqlreport\uff0c\u4eca\u5929\u5148\u4ecb\u7ecd\u8fd9\u4e2a\u5de5\u5177\u7684\u4f7f\u7528\u3002<BR>\u4e0b\u8f7d\u5e76\u6539\u53d8\u6267\u884c\u6743\u9650\uff1a<BR>wget <BR><A href=\"http:\/\/www.day32.com\/MySQL\/tuning-primer.sh\" target=_blank>http:\/\/www.day32.com\/MySQL\/tuning-primer.sh<\/A><BR><BR>chmod a+x tuning-primer.sh<BR>.\/tuning-primer.sh<BR>\u9996\u5148\u4f1a\u8981\u6c42\u8f93\u5165\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5e76\u63d0\u793a\u4fdd\u5b58\u5728\u5f53\u524d\u7528\u6237\u76ee\u5f55\u4e0b\u914d\u7f6e\u6587\u4ef6\u3002<BR>\u518d\u6b21\u6267\u884c\u811a\u672c\u5c31\u4f1a\u8fd0\u884c,\u4e0d\u7528\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5e76\u7ed9\u51fa\u53c2\u6570\u914d\u7f6e\uff0c\u5f3a\u608d\u5c31\u5f3a\u608d\u5728\u8fd9\uff01\uff01\uff01\uff01<BR>\u770b\u770b\u6211\u7684\u76f8\u5173\u63d0\u793a\uff0c<BR>[root@slave1 tuning-primer]# .\/tuning-primer.sh <BR>&#8211; INITIAL LOGIN ATTEMPT FAILED &#8211;<BR>Testing Stored for passwords: None Found<BR>&#8211; RETRY LOGIN ATTEMPT FAILED &#8211;<BR>Could not auto detect login info!<BR>Do you have your login handy ? [y\/N] : y<BR>User: root<BR>Password: <BR>Would you like me to create a ~\/.my.cnf file for you? [y\/N] : y<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&#8212; MYSQL PERFORMANCE TUNING PRIMER &#8212;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &#8211; By: Matthew Montgomery &#8211;<BR>MySQL Version 5.1.22-rc-log i686<BR>Uptime = 1 days 2 hrs 16 min 29 sec<BR>Avg. qps = 348<BR>Total Questions = 32946460<BR>Threads Connected = 23<BR>Warning: Server has not been running for at least 48hrs.<BR>It may not be safe to use these recommendations<BR>To find out more information on how each of these<BR>runtime variables effects performance visit:<BR><A href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/server-system-variables.html\" target=_blank>http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/server-system-variables.html<\/A><BR>Visit <BR><A href=\"http:\/\/www.mysql.com\/products\/enterprise\/advisors.html\" target=_blank>http:\/\/www.mysql.com\/products\/enterprise\/advisors.html<\/A><BR>for info about MySQL&#8217;s Enterprise Monitoring and Advisory Service<BR>SLOW QUERIES<BR>The slow query log is NOT enabled.<BR>Current long_query_time = 10.000000 sec.<BR>You have 44 out of 32946564 that take longer than 10.000000 sec. to complete<BR>Your long_query_time seems to be fine<BR>BINARY UPDATE LOG<BR>The binary update log is enabled<BR>The expire_logs_days is not set.<BR>The mysqld will retain the entire binary log until RESET MASTER or PURGE MASTER LOGS commands are run manually<BR>Setting expire_log_days will allow you to remove old binary logs automatically<BR>See <BR><A href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/purge-master-logs.html\" target=_blank>http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/purge-master-logs.html<\/A><BR>WORKER THREADS<BR>Current thread_cache_size = 1024<BR>Current threads_cached = 363<BR>Current threads_per_sec = 0<BR>Historic threads_per_sec = 0<BR>Your thread_cache_size is fine<BR>MAX CONNECTIONS<BR>Current max_connections = 1500<BR>Current threads_connected = 22<BR>Historic max_used_connections = 391<BR>The number of used connections is 26% of the configured maximum.<BR>Your max_connections variable seems to be fine.<BR>MEMORY USAGE<BR>Max Memory Ever Allocated : 61 G<BR>Configured Max Per-thread Buffers : 225 G<BR>Configured Max Global Buffers : 2 G<BR>Configured Max Memory Limit : 228 G<BR>Physical Memory : 3.95 G<BR>Max memory limit exceeds 90% of physical memory<BR>KEY BUFFER<BR>Current MyISAM index space = 2 G<BR>Current key_buffer_size = 512 M<BR>Key cache miss rate is 1 : 121<BR>Key buffer fill ratio = 31.00 %<BR>Your key_buffer_size seems to be too high.<BR>Perhaps you can use these resources elsewhere<BR>QUERY CACHE<BR>Query cache is enabled<BR>Current query_cache_size = 64 M<BR>Current query_cache_used = 14 M<BR>Current query_cache_limit = 2 M<BR>Current Query cache Memory fill ratio = 23.29 %<BR>Current query_cache_min_res_unit = 4 K<BR>Query Cache is 23 % fragmented<BR>Run &#8220;FLUSH QUERY CACHE&#8221; periodically to defragment the query cache memory<BR>If you have many small queries lower &#8216;query_cache_min_res_unit&#8217; to reduce fragmentation.<BR>Your query_cache_size seems to be too high.<BR>Perhaps you can use these resources elsewhere<BR>MySQL won&#8217;t cache query results that are larger than query_cache_limit in size<BR>SORT OPERATIONS<BR>Current sort_buffer_size = 4 M<BR>Current read_rnd_buffer_size = 15 M<BR>Sort buffer seems to be fine<BR>JOINS<BR>Current join_buffer_size = 4.00 M<BR>You have had 22509 queries where a join could not use an index properly<BR>join_buffer_size &gt;= 4 M<BR>This is not advised<BR>You should enable &#8220;log-queries-not-using-indexes&#8221;<BR>Then look for non indexed joins in the slow query log.<BR>OPEN FILES LIMIT<BR>Current open_files_limit = 8192 files<BR>The open_files_limit should typically be set to at least 2x-3x<BR>that of table_cache if you have heavy MyISAM usage.<BR>Your open_files_limit value seems to be fine<BR>TABLE CACHE<BR>Current table_open_cache = 2048 tables<BR>Current table_definition_cache = 128 tables<BR>You have a total of 400 tables<BR>You have 588 open tables.<BR>The table_cache value seems to be fine<BR>You should probably increase your table_definition_cache value.<BR>TEMP TABLES<BR>Current max_heap_table_size = 16 M<BR>Current tmp_table_size = 64 M<BR>Of 53670 temp tables, 44% were created on disk<BR>Effective in-memory tmp_table_size is limited to max_heap_table_size.<BR>Perhaps you should increase your tmp_table_size and\/or max_heap_table_size<BR>to reduce the number of disk-based temporary tables<BR>Note! BLOB and TEXT columns are not allow in memory tables.<BR>If you are using these columns raising these values might not impact your <BR>ratio of on disk temp tables.<BR>TABLE SCANS<BR>Current read_buffer_size = 127 M<BR>Current table scan ratio = 407 : 1<BR>read_buffer_size is over 8 MB there is probably no need for such a large read_buffer<BR>TABLE LOCKING<BR>Current Lock Wait ratio = 1 : 3135582<BR>Your table locking seems to be fine<\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql\u4e0btuner-primer\u4f7f\u7528\u8bf4\u660e mysql tuner-primer\u662f\u68c0\u6d4bmysql\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6my.cnf\u7684\u6709\u529b\u5de5\u5177\uff0c\u5f53\u7136\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\uff0c\u6bd4\u5982mysqlreport\uff0c\u4eca\u5929\u5148\u4ecb\u7ecd\u8fd9\u4e2a\u5de5\u5177\u7684\u4f7f\u7528\u3002\u4e0b\u8f7d\u5e76\u6539\u53d8\u6267\u884c\u6743\u9650\uff1awget http:\/\/www.day32.com\/MySQL\/tuning-primer.shchmod a+x tuning-primer.sh.\/tuning-primer.sh\u9996\u5148\u4f1a\u8981\u6c42\u8f93\u5165\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5e76\u63d0\u793a\u4fdd\u5b58\u5728\u5f53\u524d\u7528\u6237\u76ee\u5f55\u4e0b\u914d\u7f6e\u6587\u4ef6\u3002\u518d\u6b21\u6267\u884c\u811a\u672c\u5c31\u4f1a\u8fd0\u884c,\u4e0d\u7528\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5e76\u7ed9\u51fa\u53c2\u6570\u914d\u7f6e\uff0c\u5f3a\u608d\u5c31\u5f3a\u608d\u5728\u8fd9\uff01\uff01\uff01\uff01\u770b\u770b\u6211\u7684\u76f8\u5173\u63d0\u793a\uff0c[root@slave1 tuning-primer]# .\/tuning-primer.sh &#8211; INITIAL LOGIN ATTEMPT FAILED &#8211;Testing Stored for passwords: None Found&#8211; RETRY LOGIN ATTEMPT FAILED &#8211;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&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&#8212; &hellip; <a href=\"https:\/\/www.strongd.net\/?p=505\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">mysql tuner-primer<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[89],"class_list":["post-505","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-tuner-primer"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=505"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":864,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/505\/revisions\/864"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}