CentOS7.4 Modifying the maximum number of mariadb database connections

Source: Internet
Author: User

Why modify this? Because I zabbix-server log error, prompt connection to database ' Zabbix ' failed: [1040] Too Many connections error, mariadb normal. Think of the maximum number of MySQL connections that should be the problem.

1, see the default maximum number of connections, the default is 151

[[email protected] zabbix]# /usr/bin/mysql -u  Root -penter password: welcome to the mariadb monitor.  commands  end with ; or \g.your mariadb connection id is 14872server  version: 5.5.56-MariaDB MariaDB ServerCopyright  (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. Modify the/ETC/MY.CNF configuration file
Add a new line in [mysqld]:

[Email protected] zabbix]# vi/etc/my.cnfmax_connections=1000

Restart the MARIADB service and verify the maximum number of connections (not shown we modified):

[[email protected] zabbix]# systemctl restart mariadb.service[[email protected]  zabbix]# /usr/bin/mysql -u root -penter password: welcome to the  mariadb monitor.  commands end with ; or \g.your mariadb  connection id is 446Server version: 5.5.56-MariaDB MariaDB  servercopyright  (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, configure the/usr/lib/systemd/system/mariadb.service to adjust the number of open files.

[[email protected] zabbix]# vi/usr/lib/systemd/system/mariadb.service in the [Service] new add these two lines: limitnofile=10000limitnproc= 10000


4. Reload the system service and restart the MARIADB service

[Email protected] zabbix]# systemctl--system daemon-reload[[email protected] zabbix]# systemctl restart Mariadb.service


5, re-verify, whether it is 1000

MariaDB [(None)]> show variables like ' max_connections '; ERROR 2006 (HY000): MySQL server has gone awayno connection. Trying to reconnect ... Connection id:5current Database: * * * NONE ***+-----------------+-------+| variable_name | Value |+-----------------+-------+| max_connections | |+-----------------+-------+1 row in Set (0.00 sec)


CentOS7.4 Modifying the maximum number of mariadb database connections

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.