CentOS7.4 修改mariadb数据库最大连接数
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CentOS7.4 修改mariadb数据库最大连接数,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2601字,纯文字阅读大概需要4分钟。
内容图文
为什么修改这个?因为我zabbix-server日志报错,提示connection to database 'zabbix' failed: [1040] Too many connections错误,mariadb正常。想到应该是mysql最大连接数问题。1、查看默认最大连接数,默认是151
[root@localhost zabbix]# /usr/bin/mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14872 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 151 | +-----------------+-------+ 1 row in set (0.00 sec)
2、修改/etc/my.cnf配置文件
在[mysqld]新添加一行:
[root@localhost zabbix]# vi /etc/my.cnf max_connections=1000
重启mariadb服务,并验证最大连接数(没显示我们修改的):
[root@localhost zabbix]# systemctl restart mariadb.service [root@localhost zabbix]# /usr/bin/mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 446 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 214 | +-----------------+-------+ 1 row in set (0.00 sec)
3、配置/usr/lib/systemd/system/mariadb.service来调大打开文件数目。
[root@localhost zabbix]# vi /usr/lib/systemd/system/mariadb.service 在[Service]新加这两行: LimitNOFILE=10000 LimitNPROC=10000
4、重新加载系统服务,并重启mariadb服务
[root@localhost zabbix]# systemctl --system daemon-reload [root@localhost zabbix]# systemctl restart mariadb.service
5、重新验证下,是否为1000
MariaDB [(none)]> show variables like 'max_connections'; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 5 Current database: *** NONE *** +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | +-----------------+-------+ 1 row in set (0.00 sec)
CentOS7.4 修改mariadb数据库最大连接数
标签:mariadb数据库最大连接数 mysql最大连接数 mysql数据库最大连接数 数据库最大连接数
本文系统来源:http://blog.51cto.com/net881004/2089199
内容总结
以上是互联网集市为您收集整理的CentOS7.4 修改mariadb数据库最大连接数全部内容,希望文章能够帮你解决CentOS7.4 修改mariadb数据库最大连接数所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。