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