Too many connections 要点:
ERROR 1040 (08004): Too many connectionsMysqL必读
解决办法,这也是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
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来调大打开文件数目.MysqL必读
配置/usr/lib/systemd/system/mariadb.service
MysqL必读
[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 | +-----------------+-------+
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。