mysql too many open files 错误解决

项目中有一个拷贝大量表格的需求。其中有一个
错误:
Out of resources when opening file 'p_82.MYD' (Errcode: 24 - Too many open files)
打开文件太多了????
然后看了一下
show global status like 'open_%';
+--------------------------+-----------+
|               Open_files |     65327 |
|             Open_streams |         0 |
|   Open_table_definitions |      1970 |
|              Open_tables |      2000 |
|             Opened_files | 150401309 |
| Opened_table_definitions |  15397310 |
|            Opened_tables |  18015763 |


Open_files |     65327 |
看一下文件打开的limit 
show global variables like 'open_%';
+------------------+-------+
| open_files_limit | 65536 |
确实太多了。。
可是没有运行任何查询啊?




show variables like 'table_open_cache';
+------------------+------+
| table_open_cache | 2000 |


这部分 table_open_cache 不会释放,再看Open_tables 为 2000,说明这2000个表格都没有释放,每个表格有分区的话都会算上,并且打开每个表格都会打开若干个文件句柄。(至少3个 frm myd myi)
假设每个表格有100个分区。2000 *100*3 = 600000>>65536


解决方案:
set global table_open_cache=100;
释放缓存的文件数。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值