MariaDB Max connect

參考
https://pjstrnad.com/mariadb-raise-number-of-connections/


The issue is that you can’t have more max_connections than open_files_limit.
Indication is at the log
Changed limits: max_open_files: 1024 max_connections: 214 table_cache: 400
So you got to /etc/my.cnf and under [mysqld] add
open_files_limit=12000
max_connections=10000
But it’s not enough. Because of the systemd there are some limits in starting the mysql server – it’s already started with mysql user.
So you need to go to /etc/security/limits.conf and add
mysql soft nofile 4096
mysql hard nofile 10240
Then settings for systemd
mkdir -p /etc/systemd/system/mariadb.service.d
vi /etc/systemd/system/mariadb.service.d/limits.conf
And then enter this to to the file:
[Service]
LimitNOFILE=infinity
that worked to me. After restart of the mysql by
systemctl daemon-reload
systemctl restart mariadb
I got the connections fixed:
mysql
MariaDB [(none)]> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 10000             |
+-------------------+
MariaDB [(none)]> SHOW VARIABLES LIKE 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 65536 |
+------------------+-------+

That’s all.