ÔõÑù½â¾ömysqlµÄtoo many connectionsÎÊÌâ?
¿ÉÒԲο¼ÏÂÁÐÎÄÕÂ
http://www.mysqlperformanceblog.com/2010/03/23/too-many-connections-no-problem/
½áÂÛÈçÏ£º
£¨1£©mysqlĬÈÏ»á¸øsuperÓû§ÁôÒ»¸öÁ¬½Ó£¬Äã¿ÉÒÔÓÃÕâ¸öÔ¤ÁôµÄÁ¬½ÓÀ´µÇ¼£¬À´Ôö¼ÓÁ¬½ÓÊý£»µ«ÊÇÈç¹ûÁ¬½ÓµÄÓû§È«ÊÇsuperȨÏ޵ģ¬ÔòÕâ¸öÔ¤ÁôµÄÁ¬½Ó²»´æÔÚ¡£Õâʱ¿ÉÒÔÓÃÒÔϵÄÃüÁîÀ´ÉèÖÃÁ¬½ÓÊý£ºgdb -p $(cat data/mysql_sandbox5087.pid) -ex "set max_connections=5000" -batch
£¨2£©wait_timoutÖ¸µÄÊÇÒ»¸öÁ¬½Ó±»¹Ø±ÕÇ°µÈ´ýµÄÃëÊý£¬ÔÚÕâ֮ǰÁ¬½Óδ¹Ø±Õ£¬×´Ì¬Îªsleep£»Òò´Ë£¬Õâ¸öÖµÒªÉèÖÃΪһ¸öºÏÊʵĽÏСµÄÖµ£¬¿ÉÒÔʹÁ¬½Ó±»»ØÊյĸü¿ì¡£
£¨3£©set global max_connections=1500¿ÉÒÔÔö´ó×î´óÁ¬½ÓÊý
£¨4£©set global max_user_connections=300£¬Õâ¸öÊÇÈκθø¶¨µÄMySQLÕË»§ÔÊÐíµÄ×î´óͬʱÁ¬½ÓÊý£¬¿ÉÒÔ·Àֹijһ¸öÓû§¶ÔmysqlÁ¬½Ó¹ý¶à¡£
£¨5£©interactive_timeout£¬·þÎñÆ÷¹Ø±Õ½»»¥Ê½Á¬½ÓÇ°µÈ´ý»î¶¯µÄÃëÊý£¨½»»¥Ê½Á¬½ÓÊÇÀàËÆÓÚÏñmysql¹ÜÀí¹¤¾ßÖÐÁ¬½ÓmysqlµÄ»á»°£©
Ïà¹ØÎĵµ£º
¡¡MySQLµÄ×Ô´øÒýÇæ¿Ï¶¨Êǹ»ÓÃÁË£¬µ«ÊÇÔÚÓÐЩÇé¿öÏ£¬ÆäËûµÄÒýÇæ¿ÉÄÜÒª±ÈÊÖÍ·ËùÓøüÊʺÏÍê³ÉÈÎÎñ¡£Èç¹ûÔ¸ÒâµÄ»°£¬ÄãÉõÖÁ¿ÉÒÔʹÓÃMySQL++ APIÀ´´´½¨×Ô¼ºµÄÊý¾Ý¿âÒýÇ棬¾ÍÏñ´ò´©Æø¸××°ÉÏ×Ô¼ºµÄ»¯ÓÍÆ÷¡£ÏÖÔÚÈÃÎÒÃÇÀ´¿´¿´Äã¸ÃÈçºÎÑ¡ÔñÒýÇ棬ÒÔ¼°ÈçºÎÔÚ¿ÉÓÃÒýÇæÖ®¼äÇл»¡£
¡¡¡¡
¡¡¡¡Ñ¡ÔñÄãµÄÒýÇæ
¡¡¡¡
¡¡¡¡ÄãÄÜÓõÄÊý¾Ý¿ ......
MySQL²éѯ±íÄÚÖظ´¼Ç¼
²éѯ¼°É¾³ýÖظ´¼Ç¼µÄ·½·¨
(Ò»)
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΠ......
Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁ ......
apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ
ÎÒÏë´ó¼ÒÓв»ÉÙ¶¼³É¹¦ÊµÏÖapache+php+mysql£¬ÍøÉϵÄÎÄÕÂÒ²Óв»ÉÙ£¬µ«ÎÒ·¢ÏÖ²»ÉÙÎÄÕ¶¼ÊdzÀ´³È¥£¬²¢ÇÒ
ûÓÐ˵Ã÷°×±àÒëµÄ·½Ê½£¬ÓеÄË÷ÐÔapache1.3µÄ±àÒë·½·¨Ô·â²»¶¯µÄ°á¹ýÀ´Ì×ÔÚapache2.0£¬ÏÔÈ»Îóµ¼Ò»Ð©²ËÄñ £¡
ÎÒ½ñÌì¾ÍÒÔapache+mysql+php˵һϾ²Ì¬±àÒëºÍDSO¶¯Ì¬±à ......