Ubuntu 8.04 上打开文件过多错误
mysqldump: Couldn't execute 'show fields from `tablename`': Out of resources when opening file './databasename/tablename#P#p125.MYD' (Errcode: 24) (23)
在检查 shell 上的错误 24 时,它说
>>perror 24
OS error code 24: Too many open files
我该如何解决这个问题?
mysqldump: Couldn't execute 'show fields from `tablename`': Out of resources when opening file './databasename/tablename#P#p125.MYD' (Errcode: 24) (23)
on checking the error 24 on the shell it says
>>perror 24
OS error code 24: Too many open files
how do I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
首先,要确定特定的用户或组限制,您必须执行以下操作:
重要的一行是:
open files (-n) 1024
如您所见,您的操作系统供应商附带此版本基本的 Linux 配置 - 每个进程 1024 个文件。
这对于繁忙的 MySQL 安装来说显然是不够的。
现在,要解决此问题,您必须修改以下文件:
/etc/security/limits.conf
某些版本的 Linux 还需要额外的配置,以使其坚持守护进程而不是登录会话。 例如,在 Ubuntu 10.04 中,您还需要通过将以下行添加到
/etc/pam.d/common-session
来设置 pam 会话限制:At first, to identify the certain user or group limits you have to do the following:
The important line is:
open files (-n) 1024
As you can see, your operating system vendor ships this version with the basic Linux configuration - 1024 files per process.
This is obviously not enough for a busy MySQL installation.
Now, to fix this you have to modify the following file:
/etc/security/limits.conf
Some flavors of Linux also require additional configuration to get this to stick to daemon processes versus login sessions. In Ubuntu 10.04, for example, you need to also set the pam session limits by adding the following line to
/etc/pam.d/common-session
:这是一个很老的问题,但这是我的两分钱。
您可能遇到的问题是 mysql 引擎没有正确设置其变量“open-files-limit”。
你可以看到你允许mysql打开多少个文件
mysql> 显示变量;
即使您已经将限制设置为更高的值,也可能设置为 1024。
您可以在 mysqld 的命令行中使用选项 --open-files-limit=XXXXX。
干杯
Quite an old question but here are my two cents.
The thing that you could be experiencing is that the mysql engine didn't set its variable "open-files-limit" right.
You can see how many files are you allowing mysql to open
mysql> SHOW VARIABLES;
Probably is set to 1024 even if you already set the limits to higher values.
You can use the option --open-files-limit=XXXXX in the command line for mysqld.
Cheers
将 --single_transaction 添加到 mysqldump 命令
add --single_transaction to your mysqldump command
也有可能通过某些访问表的代码无法正确关闭这些表,并且在某个时间点上可以达到打开文件的数量。
请参考http://dev.mysql.com/doc /refman/5.0/en/table-cache.html 也有可能的原因。
重新启动 mysql 应该会导致这个问题消失(尽管除非根本问题得到解决,否则它可能会再次发生)。
It could also be possible that by some code that accesses the tables dint close those properly and over a point of time, the number of open files could be reached.
Please refer to http://dev.mysql.com/doc/refman/5.0/en/table-cache.html for a possible reason as well.
Restarting mysql should cause this problem to go away (although it might happen again unless the underlying problem is fixed).
您可以通过编辑 /etc/security/limits.conf 来增加操作系统限制。
您还可以安装“lsof”(LiSt Open Files)命令来查看文件< -> 进程关系。
You can increase your OS limits by editing /etc/security/limits.conf.
You can also install "lsof" (LiSt Open Files) command to see Files <-> Processes relation.
我认为没有必要配置 PAM。 在我的系统(Debian 7.2 和 Percona 5.5.31-rel30.3-520.squeeze )上,我有: 在
my.cnf 更改之前:
在将“open_files_limit = 4096”添加到 my.cnf 并重启 mysqld 后,我得到:
12345 和 23456当然是mysqld进程PID。
SHOW VARIABLES LIKE 'open_files_limit' 现在显示 4096。
一切看起来都不错,而“ulimit”没有显示任何变化:
There are no need to configure PAM, as I think. On my system (Debian 7.2 with Percona 5.5.31-rel30.3-520.squeeze ) I have:
Before my.cnf changes:
After adding "open_files_limit = 4096" into my.cnf and mysqld restart, I got:
12345 and 23456 is mysqld process PID, of course.
SHOW VARIABLES LIKE 'open_files_limit' show 4096 now.
All looks ok, while "ulimit" show no changes:
无法保证“24”是操作系统级别的错误号,因此不要假设这意味着打开了太多文件句柄。 它可能是 mysql 本身使用的某种类型的内部错误代码。 我建议在 mysql 邮件列表上询问这个问题。
There is no guarantee that "24" is an OS-level error number, so don't assume that this means that too many file handles are open. It could be some type of internal error code used within mysql itself. I'd suggest asking on the mysql mailing lists about this.