[ERROR] Error in accept: Too many open files

环境和前提:
mysql 5.7.32
CentOS Linux release 7.9.2009 (Core)
open-files-limit = 16384

现象:
连接数接近了5000
报错 [ERROR] Error in accept: Too many open files

root@(none) 17:24:24> show global variables like '%open%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| have_openssl | YES |
| innodb_open_files | 995 |
| open_files_limit | 5000 |
| table_open_cache | 995 |
| table_open_cache_instances | 16 |
+----------------------------+-------+

[root@ooxx logs]# ulimit -a
..........
open files (-n) 61000

分析:
[root@5jdb01 33950]# more limits
Limit Soft Limit Hard Limit Units
..........
Max open files 5000 5000 files

和我配置文件中的open-files-limit值对不上,没生效

open_files_limit 这个数字少了点,这里有个算法:
max_open_files_1 = max_connections + table_cache * 2 = 100 + 1000 * 2 = 2100
max_open_files_2 = max_connections*5 = 100 * 5 = 500

解决方法:
vim /lib/systemd/system/mysqld.service

LimitNOFILE = 61000
重启MySQL服务

全局修改方法:
vim /etc/systemd/system.conf
DefaultLimitCORE=infinity
DefaultLimitNOFILE=61000
DefaultLimitNPROC=61000
重启服务器使之生效

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容