MySQL 句柄数过多"too many open files"问题解决
问题分析
MySQL进程打开文件句柄过多,无法再打开新的文件句柄
问题确认
// 系统单个进程最大文件句柄数量查看
ulimit -n
// 查看某个个进程使用的文件句柄数量
lsof -p ${PID} | wc -l
// 查看MySQL的table_open_cache参数
show variables like "table_open_cache";
// 查看MySQL的open_tables参数
show global status like "open_tables";
解决办法
// 修改MySQL的table_open_cache参数
// 编辑my.cnf
table_open_cache = 65535
// 编辑/etc/security/limits.conf
#限制单个进程最大文件句柄数(到达此限制时系统报警)
* soft nofile 32768
#限制单个进程最大文件句柄数(到达此限制时系统报错)
* hard nofile 65536