- 原因:打开文件数量太多,超出了
open_files_limit这个参数的限制,在一个表中有多个分区的时候,这种情况更容易发生。 - 解决方法:
- 查看
open_files_limit参数
使用show variables like '%open%';就可以看到了
如上图,改参数的大小为1024 - 修改
open_files_limit参数
在网上找了很多资料,有的说直接在/etc/mysql/mysql.conf.d/mysqld.cnf文件中的[mysqld]部分添加open_files_limit参数,比如open_files_limit=102400,并且在/etc/security/limits.conf添加mysql soft nofile 102400和mysql hard nofile 102400这两个参数然后重启MySQL,但是发现不能生效。
以下方法可用:
在文件/etc/systemd/system/multi-user.target.wants/mysql.service(也有可能是/etc/systemd/system/mysql.service这个文件)最后添加LimitNOFILE=102400
然后执行systemctl daemon-reload,接着再重启mysql服务sudo service mysql restart,可以看到已经修改成功了。
- 查看
相关文章: