MySQl 淇敼鏈€澶ц繛鎺ユ暟

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQl 淇敼鏈€澶ц繛鎺ユ暟相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ide' title='ide'>ide   handles   com   mysql杩炴帴   鐢熸晥   mit   甯姪   閲嶅惎   瀵艰嚧   

浠婂ぉ浣跨敤ide杩炴帴绾夸笅MySQL鎶ラ敊Can not connect to MySQL server. Too many connections锛屾姤閿欏緢鏄庣‘锛屼笌MySQL鐨勮繛鎺ユ暟婊′簡銆傛兂鎯充篃鏄紝姣忚捣涓€涓湇鍔¢兘浼氬垱寤篗ySQL杩炴帴姹狅紝鍗犵敤涓嶅皯鐨勯暱杩炴帴銆傜敤ide鏌ョ湅浜嗕竴涓嬶紝鍘熸潵鏈€澶ц繛鎺ユ暟鎵?51锛岀湅鏉ユ湁蹇呰鏀瑰ぇ涓€鐐逛簡銆?/span>

涓婄綉鏌ヤ簡涓€涓嬶紝淇敼鏂瑰紡鏈変袱绉?/span>

1.鍛戒护琛屼慨鏀?/span>

杩涘叆mysql鍚庯紝set GLOBAL max_connections=1024; 鍗冲彲绔嬪嵆鐢熸晥锛屼絾鏄崥涓绘病鏈変娇鐢ㄨ繖绉嶆柟寮忥紝鍥犱负杩欑鏂规硶娌绘爣涓嶆不鏈紝涓€鐐归噸鍚痬ysql锛屾渶澶ц繛鎺ユ暟鍙堜細鍙樺洖151

2.淇敼閰嶇疆锛岀劧鍚庨噸鍚?/span>

vi /etc/m.cnf鍔犲叆max_connections=1024锛岀劧鍚庨噸鍚痬ysql鍗冲彲銆?/span>

閲嶅惎鍚庯紝寰堥仐鎲撅紝max_connections鍙樻垚浜?14锛岃繖灏卞緢璇″紓浜嗐€傛垜鎶妋ax_connections鍙堝垎鍒缃垚500鍜?13锛屽疄闄呯殑max_connections鍒嗗埆鏄?14鍜?13銆備篃灏辨槸璇达紝鍦ㄨ繖鍙版湇鍔″櫒涓婏紝max_connections鏈€澶у彧鑳芥槸234锛岀寽娴嬫槸鍥犱负鎿嶄綔绯荤粺鐨勯檺鍒跺鑷磎ax_connections鏈€澶у彧鑳戒负213銆傚崥涓荤炕浜嗙炕MySQl瀹樻柟鏂囨。锛堣嫳璇笉濂界湅鏂囨。鐪熸槸娴戣韩闅惧彈)锛屽彂鐜颁互涓嬪嚑鍙ヨ瘽锛?/span>

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the amount of RAM available, how much RAM is used for each connection, the workload from each connection, and the desired response time. Increasing open-files-limit may be necessary. Also see Section 2.5, 鈥淚nstalling MySQL on Linux鈥? for how to raise the operating system limit on how many handles can be used by MySQL.

浠ユ垜鐨勮嫳璇按鍑嗭紝鎶婁笂杩拌鍙ユ鎷捣鏉ュ氨鏄紝max_connections渚濇墭浜庢搷浣滅郴缁燂紝Linux绯荤粺蹇呰鏃堕渶瑕佸鍔爋pen-files-limit銆備竾涓囨病鎯冲埌鍟婏紝淇敼max_connections绔熺劧瑕佷慨鏀规搷浣滅郴缁熸渶澶ф枃浠舵弿杩扮銆?/span>

vi /usr/lib/systemd/system/mysqld.service鍔犲叆

LimitNOFILE=50000

閲嶅惎MySQL

鍡紝鎼炲畾浜嗭綖

甯屾湜瀵瑰ぇ瀹舵湁鎵€甯姪锛岀澶у姣忓ぉ寮€蹇冿綖

以上是关于MySQl 淇敼鏈€澶ц繛鎺ユ暟的主要内容,如果未能解决你的问题,请参考以下文章

閰嶇疆php.ini 淇敼php鏂囦欢涓婁紶澶у皬

mongodb鐨勮繛鎺ユ睜绠$悊

闈㈣瘯瀹橈細鏁版嵁搴撹繛鎺ユ睜涓轰粈涔堥兘瑕佺敤Threadlocal鍛紵

澶ц妯℃暟鎹浣曟绱紵

澶у巶鍓嶇寮€鍙戯紝蹇呭宸ュ叿闆嗗悎

SSL/TLS娣卞害瑙f瀽--TLS鎬ц兘浼樺寲