【查看mysql最大链接数】

MariaDB [(none)]> show variables like 'max_connections';

   

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 151 |

+-----------------+-------+

   

【配置/etc/my.cnf

[mysqld]新添加一行:

max_connections=1000

   

重启mariadb服务,再次查看最大连接数,发现是214,而不是我们设置的1000。

   

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 214 |

+-----------------+-------+

   

这是由于mariadb有默认打开文件数限制。

可以通过配置 /usr/lib/systemd/system/mariadb.service 来调大打开文件数目。

   

【配置 mariadb.service

   

[Service]新添加两行:

LimitNOFILE=10000

LimitNPROC=10000

   

【重新加载系统服务并重启】

systemctl --system daemon-reload

systemctl restart mariadb.service

   

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 1000 |

+-----------------+-------+

   

然后我们发现最大连接数已经发生了变化。

相关文章:

  • 2021-11-19
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-05-04
猜你喜欢
  • 2021-11-22
  • 2021-07-05
  • 2021-08-17
  • 2022-02-15
  • 2021-07-17
相关资源
相似解决方案