1. Check mariadb the maximum number of connections to the database, the default is 151
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
2. Configure /etc/my.cnf
[mysqld] Add a new row following parameters:
max_connections=1000
Restart mariadb service, check back mariadb the maximum number of connections to the database, you can see the maximum number of connections is 214 , not our set of 1000 .
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
This is due to mariadb has a default open file limit. You can be configured /usr/lib/systemd/system/mariadb.service to transfer large number of open files.
3. Configure /usr/lib/systemd/system/mariadb.service
[Service] new add two lines of the following parameters:
LimitNOFILE = 10000
LimitNPROC = 10000
4. reload system services, and restart mariadb Service
systemctl --system daemon-reload
systemctl restart mariadb.service
Check again mariadb the maximum number of connections to the database, you can see already the maximum number of connections 1000
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
---------------------