Out of resources when opening file ‘./xxx.MYD’ (Errcode: 24)解决方法

时间:2023-03-09 18:19:03
Out of resources when opening file ‘./xxx.MYD’ (Errcode: 24)解决方法

今天朋友向我反映网站出现错误:Out of resources when opening file './xxx.MYD' (Errcode: 24)错误是因为打开的文件数超过了my.cnf的--open-files-limit。open-files-limit选项无法在mysql命令行 直接修改,必须在my.cnf中设定. 如果你要是不设置的话,他会取系统ulimit -n的值.

出错之时,参数配置如下:

1
2
3
4
5
6
7
mysql> show variables like 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 1024  |
+------------------+-------+
1 row in set (0.00 sec)

修改open file的值,ulimit -n 204800. 或者在/etc/profile的最后一样加上ulimit -u 204800 -HSn 204800. 执行 source /etc/profile,最后重启一下数据库。

1
# service mysql restart

查看目前的情况佮.

1
2
3
4
5
6
7
mysql> show variables like 'open%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| open_files_limit | 204800 |
+------------------+--------+
1 row in set (0.00 sec)

配置数据库的时候千万不要忘记设置这个了。