Mysql优化

December 24, 2005

(1)�back_log:
�求 MySQL 能有的连接数�。当主�MySQL线程在一个很短时间内得到�常多的连接请求,这就起作用,然�主线程花些时间(尽管很短)检查连接并且�动一个新线程。
back_log值指出在MySQL暂时�止回答新请求之�的短时间内多少个请求�以被存在堆栈中。�有如果期望在一个短时间内有很多连接,你需�增加
它,���说,这值对到�的TCP/IP连接的侦�队列的大�。你的�作系统在这个队列大�上有它自己的�制。
试图设定back_log高于你的�作系统的�制将是无效的。
当你观察你的主机进程列表,�现大� 264084 | unauthenticated user | xxx.xxx.xxx.xxx |
NULL | Connect | NULL | login | NULL 的待连接进程时,就�加大 back_log
的值了。默认数值是50,我把它改为500。

(2)�interactive_timeout:
�务器在关闭它�在一个交互连接上等待行动的秒数。一个交互的客户被定义为对 mysql_real_connect()使用 CLIENT_INTERACTIVE 选项的客户。 默认数值是28800,我把它改为7200。

(3)�key_buffer_size:
索引�是缓冲的并且被所有的线程共享。key_buffer_size是用于索引�的缓冲区大�,增加它�得到更好处�的索引(对所有读和多�写),到你
能负担得起那样多。如果你使它太大,系统将开始�页并且真的�慢了。默认数值是8388600(8M),我的MySQL主机有2GB内存,所以我把它改为
402649088(400MB)。

(4)�max_connections:
å…?许的å?Œæ—¶å®¢æˆ·çš„æ•°é‡?。增加该值增加 mysqld è¦?求的文件æ??述符的数é‡?。这个数字应该增加,å?¦åˆ™ï¼Œä½ å°†ç»?常看到 Too many connections 错误。 默认数值是100,我把它改为1024 。

(5)�record_buffer:
æ¯?个进行一个顺åº?扫æ??的线程为其扫æ??çš„æ¯?张表分é…?这个大å°?的一个缓冲区。如果你å?šå¾ˆå¤šé¡ºåº?扫æ??,你å?¯èƒ½æƒ³è¦?增加该值。默认数值是131072(128K),我把它改为16773120 (16M)

(6)�sort_buffer:
�个需�进行排�的线程分�该大�的一个缓冲区。增加这值加速ORDER BY或GROUP BY�作。默认数值是2097144(2M),我把它改为 16777208 (16M)。

(7)�table_cache:
为所有线程打开表的数é‡?。增加该值能增加mysqldè¦?求的文件æ??述符的数é‡?。MySQL对æ¯?个唯一打开的表需è¦?2个文件æ??述符。默认数值是64,我把它改为512。

(8)�thread_cache_size:
å?¯ä»¥å¤?用的ä¿?存在中的线程的数é‡?。如果有,新的线程从缓存中å?–得,当断开连接的时候如果有空间,客户的线置在缓存中。如果有很多新的线程,为了æ??高性能å?¯
以这个��值。通过比较 Connections 和 Threads_created 状�的��,�以看到这个��的作用。我把它设置为 80。

(10)�wait_timeout:
�务器在关闭它之�在一个连接上等待行动的秒数。 默认数值是28800,我把它改为7200。

注:�数的调整�以通过修改 /etc/my.cnf 文件并�� MySQL 实现。这是一个比较谨慎的工作,上�的结果也仅仅是我的一些看法,你�以根�你自己主机的硬件情况(特别是内存大�)进一步修改。

Entry Filed under: Uncategorized. .

12 Comments Add your own

  • 1. Thomas  |  March 30, 2007 at 3:38 pm

    Awesome site! Design is great! Would you please also visit my site?

  • 2. Stacy  |  March 30, 2007 at 3:38 pm

    Very well! Your site is neat! Please visit my site too:

  • 3. Cathy  |  March 30, 2007 at 3:38 pm

    You have a great page! Would you please also visit my site?

  • 4. Ralph  |  March 30, 2007 at 3:40 pm

    I just want to say thank you for taking the time & effort for put this web page together! Please visit my homepage:

  • 5. Allen  |  March 30, 2007 at 3:43 pm

    Your site looks great! Please also visit my site:

  • 6. Lillian  |  March 31, 2007 at 3:16 am

    Hmm… sweet! [*../nice_site2.txt*]

  • 7. Jersey  |  April 15, 2007 at 5:37 am

    Interesting web page is, i\’ll see you later one more timeo

  • 8. Buy Viagra online luv  |  May 25, 2007 at 2:24 am

    Great work and pretty colors!

  • 9. Hillary  |  November 30, 2007 at 6:44 pm

    I browse and saw you website and I found it very interesting.Thank you for the good work, greetings

  • 10. sveta  |  December 14, 2007 at 9:44 am

    I enjoyed your page. Keep up the good work! Feel free to visit my page. It\’s cool too.r

  • 11. Helga  |  December 15, 2007 at 11:02 am

    I like it and the background and colors make it easy to readh

  • 12. Bush  |  January 13, 2008 at 11:32 am

    Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks!!i

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

December 2005
M T W T F S S
« Oct    
 1234
567891011
12131415161718
19202122232425
262728293031  

Most Recent Posts