Ubuntu 8.04 上打开文件过多错误

发布于 2024-07-13 05:32:02 字数 312 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

剑心龙吟 2024-07-20 05:32:02

首先,要确定特定的用户或组限制,您必须执行以下操作:

root@ubuntu:~# sudo -u mysql bash
mysql@ubuntu:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 71680
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 71680
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
mysql@ubuntu:~$

重要的一行是:

open files (-n) 1024

如您所见,您的操作系统供应商附带此版本基本的 Linux 配置 - 每个进程 1024 个文件。

这对于繁忙的 MySQL 安装来说显然是不够的。

现在,要解决此问题,您必须修改以下文件:

/etc/security/limits.conf

mysql             soft    nofile           24000
mysql             hard    nofile           32000

某些版本的 Linux 还需要额外的配置,以使其坚持守护进程而不是登录会话。 例如,在 Ubuntu 10.04 中,您还需要通过将以下行添加到 /etc/pam.d/common-session 来设置 pam 会话限制:

session required pam_limits.so

At first, to identify the certain user or group limits you have to do the following:

root@ubuntu:~# sudo -u mysql bash
mysql@ubuntu:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 71680
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 71680
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
mysql@ubuntu:~$

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

mysql             soft    nofile           24000
mysql             hard    nofile           32000

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:

session required pam_limits.so
老娘不死你永远是小三 2024-07-20 05:32:02

这是一个很老的问题,但这是我的两分钱。

您可能遇到的问题是 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

临走之时 2024-07-20 05:32:02

将 --single_transaction 添加到 mysqldump 命令

add --single_transaction to your mysqldump command

鹊巢 2024-07-20 05:32:02

也有可能通过某些访问表的代码无法正确关闭这些表,并且在某个时间点上可以达到打开文件的数量。

请参考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).

深居我梦 2024-07-20 05:32:02

您可以通过编辑 /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.

策马西风 2024-07-20 05:32:02

我认为没有必要配置 PAM。 在我的系统(Debian 7.2 和 Percona 5.5.31-rel30.3-520.squeeze )上,我有: 在

my.cnf 更改之前:

\#cat /proc/12345/limits |grep "open files"
Max open files            1186                 1186                 files

在将“open_files_limit = 4096”添加到 my.cnf 并重启 mysqld 后,我得到:

\#cat /proc/23456/limits |grep "open files"
Max open files            4096                 4096                 files

12345 和 23456当然是mysqld进程PID。

SHOW VARIABLES LIKE 'open_files_limit' 现在显示 4096。

一切看起来都不错,而“ulimit”没有显示任何变化:

\# su - mysql -c bash
\# ulimit -n
1024

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:

\#cat /proc/12345/limits |grep "open files"
Max open files            1186                 1186                 files

After adding "open_files_limit = 4096" into my.cnf and mysqld restart, I got:

\#cat /proc/23456/limits |grep "open files"
Max open files            4096                 4096                 files

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:

\# su - mysql -c bash
\# ulimit -n
1024
叹沉浮 2024-07-20 05:32:02

无法保证“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文