MySQL中的max_connections和max_user_connections 及 MySQL伺服器最大串連數的合理設定

來源:互聯網
上載者:User

標籤:

max_connections 是指整個mysql伺服器的最大串連數;

max_user_connections 是指每個資料庫使用者的最大串連數,比如:虛擬機器主機可以用這個參數控制每個虛擬機器主機使用者的資料庫最大串連數;

 

MySQL伺服器的串連數並不是要達到最大的100%為好,還是要具體問題具體分析,下面就對MySQL伺服器最大串連數的合理設定進行了詳盡的分析,供您參考。

我們經常會遇見“MySQL: ERROR 1040: Too many connections”的情況,一種是訪問量確實很高,MySQL伺服器抗不住,這個時候就要考慮增加從伺服器分散讀壓力,另外一種情況是MySQL設定檔中max_connections值過小:

mysql> show variables like ‘max_connections‘;+-----------------+-------+| Variable_name | Value |+-----------------+-------+| max_connections | 256 |+-----------------+-------+

 這台MySQL伺服器最大串連數是256,然後查詢一下伺服器響應的最大串連數:

mysql> show global status like ‘Max_used_connections‘;

 MySQL伺服器響應的最大串連數是245,沒有達到伺服器串連數上限256,應該不會出現1040錯誤,比較理想的設定是:

Max_used_connections / max_connections * 100% ≈ 85%

 響應串連數占上限串連數的85%左右,如果發現比例在10%以下,MySQL伺服器串連上線就設定得過高了。

MySQL中的max_connections和max_user_connections 及 MySQL伺服器最大串連數的合理設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.