在一次部署物理机时开发那边报没法链接数据库,登陆后台查看发现登陆不上,报链接数太多,重启数据库登陆后查看链接数 查询Mysql 最大链接数:
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 214 |
+-------------------+
1 row in set (0.00 sec)
Mysql 配置文件链接数:
max_connections = 3000mysql
Mysql 重启后日志:
2019-06-27T01:27:04.352761Z 0 [Warning] Could not increase number of max_open_files to more than 1024 (request: 65535)
2019-06-27T01:27:04.352836Z 0 [Warning] Changed limits: max_connections: 214 (requested 3000)
2019-06-27T01:27:04.352843Z 0 [Warning] Changed limits: table_open_cache: 400 (requested 4096)sql
查看系统max_open_files以下:数据库
正常的数据库以下:ide
查看问题所在,查看对应的进程限制
ps -ef |grep mysqld
查看资源管理
查看用户会话的状态
查看用户会话的位置配置
修改/lib/systemd/system/rc-local.service配置文件
vi /lib/systemd/system/rc-local.service
LimitNOFILE=65535
加载配置文件,重启机器日志
查看最大文件的限制code
查看数据库日志,发现已经没有以前的警告了
查看数据库的最大链接数,已恢复正常
mysql> show variables like 'max_conne%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 500 |
| max_connections | 3000 |
+--------------------+-------+
2 rows in set (0.00 sec)blog
至此已彻底处理了配置文件链接数不生效问题进程