mysql maxopenfiles_mysql备份提示 too many open files Errornumber 24

一.问题的描述

备份程序 执行前滚的时候报错。

InnoDB: Errornumber 24 means 'Too many open files'.

InnoDB: Some operatingsystem error numbers are described at

InnoDB: http://dev.MySQL.com/doc/mysql/en/Operating_System_error_codes.html

InnoDB: File name/home/nice/backup/mysql/var.20121211021656/user_db_20121123/tuser_like_core.ibd

InnoDB: File operationcall: 'open'.

InnoDB: Cannot continueoperation.

innobackup:Error:

二.问题分析

openfiles 开的小了。

mysql的open_file_limit受制于以下几个参数

max_connections、 table_open_cache 、open_files_limit 以及 /etc/security/limits.conf中的配置。

max_connections和 table_open_cache 与open_files_limit 的关系:

max_1 = 10 + max_connections + table_cache * 2;

max_2 = max_connections * 5;

max_3 = max_os_open_files;//操作系统单个进程最大允许打开文件句柄(文件描述符)。

open_files_limit= max( max_1, max_2 ) > max_3 ? max_3 : max ( max_1, max_2);

综合分析发现,open_files_limit  | 10240

而目前ibd表已经10800个了。

三.解决问题

1.my.cnf  配置 open_files_limit         = 20480

重启mysql 发现没有变化,open_files_limit  | 10240。

2.ulimit -a

core file size          (blocks, -c) unlimited

data seg size           (kbytes, -d) unlimited

file size               (blocks, -f) unlimited

pending signals                 (-i) 1024

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

stack size              (kbytes, -s) 10240

cpu time               (seconds, -t) unlimited

max user processes              (-u) 137216

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

3.vi /etc/security/limits.conf,添加

mysql            soft    nofile          8192

mysql            hard    nofile          20480

4.经过前三步,重启mysql。

重启mysql 发现,open_files_limit  | 20480。

5.修改OS用户配置文件

经过前四步,虽然在mysql中 看open_files_limit  | 20480,但ibbackup还是在前滚时报错。报,open_file不够。怀疑 还是没有生效。

ulimit -a

core file size          (blocks, -c) unlimited

data seg size           (kbytes, -d) unlimited

file size               (blocks, -f) unlimited

pending signals                 (-i) 1024

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

stack size              (kbytes, -s) 10240

cpu time               (seconds, -t) unlimited

max user processes              (-u) 137216

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

于是,修改OS用户配置文件

分别查看了.bash_profile 、.bashrc 、/etc/bashrc;

发现,.bash_profile调用 .bashrc ,.bashrc调用 /etc/bashrc

发现,/etc/bashrc 中有

ulimit -S -c unlimited > /dev/null 2>&1

在这一行之后 添加

ulimit -n 20480 >/dev/null 2>&1

6.重启mysql ,执行备份程序,在--apply-log,还是报错,报,open_file不够

InnoDB: Errornumber 24 means 'Too many open files'.

InnoDB: Some operatingsystem error numbers are described at

InnoDB: http://dev.mysql.com/doc/mysql/en/Operating_System_error_codes.html

7.修改innodb_open_files 参数

之前这个参数,设置成500.这次修改到1000.

重启mysql 解决问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误表示打开的文件数超过了操作系统的限制。当MySQL服务器尝试打开一个新的文件时,操作系统会限制打开的文件数目,如果超过了限制就会出现这个错误。 要解决这个问题,可以尝试以下几个步骤: 1. 确认错误日志:首先,查看MySQL的错误日志文件,通常是在MySQL的数据目录下的`hostname.err`文件中。日志中会显示具体的错误信息和可能的原因。 2. 增加文件描述符限制:可以通过修改操作系统的文件描述符限制来解决这个问题。在Linux系统中,可以通过修改`/etc/security/limits.conf`文件来增加限制。例如,可以添加以下行来增加文件描述符的限制: ``` * soft nofile 65535 * hard nofile 65535 ``` 然后重新登录或重启系统生效。 3. 优化MySQL参数:如果增加文件描述符限制后问题仍然存在,可以尝试优化MySQL的一些参数来减少打开的文件数目。例如,可以尝试减少`table_open_cache`和`open_files_limit`参数的值。 4. 检查数据库连接池:如果你使用了数据库连接池,确保连接池正确关闭和释放连接,避免连接泄露。 5. 检查应用程序代码:有时候,应用程序在使用数据库连接后没有正确关闭连接,导致连接没有释放。确保在使用完数据库连接后,及时关闭连接。 通过以上一些步骤,你应该能够解决MySQL的"OS errno 24 - Too many open files"错误。如果问题仍然存在,可以进一步查看MySQL的文档或寻求专业的支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值