解决使用innobackupex备份mysql产生returned OS error 124【转】

###简介

今天在使用innobackupex全量备份数据库的时候发生了下面的错误

错误详情

190705 15:22:18 >> log scanned up to (258819807308)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 565 for new/sgk, old maximum was 0
InnoDB: Operating system error number 24 in a file operation.
InnoDB: Error number 24 means 'Too many open files'
InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
InnoDB: File ./GroupData5/Group499.ibd: 'open' returned OS error 124. Cannot continue operation
InnoDB: Cannot continue operation.

解决方式

这个是指mysql进程超出了打开最多的文件数量,检查下mysql数据文件data目录下的文件总数。

[root@nbpi-centos-tpl backup]# find /data -type f|wc -l
2644

 

接着我们查看mysql中innodb_open_files这个参数

登录mysql,执行

mysql> show variables like '%open_files%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| innodb_open_files | 2000  |
| open_files_limit  | 5000  |
+-------------------+-------+
2 rows in set (0.00 sec)

 

innodb_open_files的意思是限制Innodb能打开的表的数据。

这里设置的是2000默认值,但是数据库文件已经达到2644个了,所以报错,我们修改my.cnf中这个数值,之后重启就好了,如果没有,那就添加上

vim /etc/my.cnf

[mysqld]下加入innodb_open_files=5000

之后重启服务器

systemctl restart mysql

登录数据库查看验证一下

show variables like '%open_files%';

之后重新备份就没有这个错误了,如果还有那么就是系统可以打开的最大文件数目的问题了,执行

ulimit -a

查看系统open files这个值,之后使用

ulimit -n 5000

设置大就好了

我是设置ulimit -n 5000后执行备份就正常了。

posted @ 2022-12-16 12:26  paul_hch  阅读(186)  评论(0编辑  收藏  举报