mysql串連數設定作業(Too many connections)

來源:互聯網
上載者:User

標籤:使用   mysql   space   man   adb   mysqld   max   res   載入   

mysql在使用過程中,發現串連數超了~~~~

[[email protected] ~]# mysql -u glance -h 192.168.1.17 -p
Enter password: 
ERROR 1040 (08004): Too many connections

解決辦法,這也是centos7下修改mysql串連數的做法:
1)臨時修改
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> set GLOBAL max_connections=1000; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)

2)永久修改:
配置/etc/my.cnf
[mysqld]新添加一行如下參數:
max_connections=1000
重啟mariadb服務,再次查看mariadb資料庫最大串連數,可以看到最大串連數是214,並非我們設定的1000。
MariaDB [(none)]> show variables like ‘max_connections‘; 
+-----------------+-------+ 
| Variable_name | Value | 
+-----------------+-------+ 
| max_connections | 214 | 
+-----------------+-------+ 
這是由於mariadb有預設開啟檔案數限制。可以通過配置/usr/lib/systemd/system/mariadb.service來調大開啟檔案數目。

配置/usr/lib/systemd/system/mariadb.service
[Service]新添加兩行如下參數:
LimitNOFILE=10000
LimitNPROC=10000

重新載入系統服務,並重啟mariadb服務
systemctl --system daemon-reload 
systemctl restart mariadb.service

再次查看mariadb資料庫最大串連數,可以看到最大串連數已經是1000
MariaDB [(none)]> show variables like ‘max_connections‘; 
+-----------------+-------+ 
| Variable_name | Value | 
+-----------------+-------+ 
| max_connections | 1000 | 
+-----------------+-------+

mysql串連數設定作業(Too many connections)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.