作者:汤薇
爱可生南区DBA组成员,主要负责MySQL的日常维护及故障处理。擅长多种数据库的运维经验及故障调优。
本文来源:原创投稿
*爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。
一、背景描述
最近使用 xtrabackup 工具对 mysql 实例进行备份时,由于实例的 ibd 文件过多,而备份用户 的 open files 参数设置的值太小,在备份实例时打开的文件数量超过了备份用户允许打开的文件 数量限制,导致备份失败,其报错如下:
220330 08:28:47 >> log scanned up to (328701072168)
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 ./stage/ts_cg_inteltaxtochanges #P#P_20220322.ibd: 'open' returned OS
error 124. Cannot continue operation
InnoDB: Cannot continue operation.
二、模拟故障场景
1、环境说明
mysql 版本: v5.7.35
xtrabackup 版本:v2.4.24
2、查看 open files 的已知参数值
(1)操作系统当前的 open files 数量
[root@test ~]# ulimit -a
core file size (blocks, -c) 0
...
open files (-n) 1024
...
(2)mysql 实例配置文件 my.cnf 的 innodb_file_per_table、open_files_limit 参数值
[root@test ~]# less /opt/mysql/etc/3306/my.cnf |grep innodb_file_per_table
innodb_file_per_table = 1
[root@test ~]# less /opt/mysql/etc/3306/my.cnf |grep open_files_limit
open_files_limit = 20000
(3)备份用户 actiontech-mysql 在 /etc/security/limits.d 中的配置文件的 open files 的限制
[root@test ~]# cd /etc/security/limits.d
[root@test limits.d]# cat actiontech-mysql.conf
actiontech-mysql soft nofile 10240
actiontech-mysql hard nofile 10240
actiontech-mysql soft

本文通过实例详细分析了在使用xtrabackup工具备份MySQL时遇到的'Too many open files'错误。故障源于open_files_limit配置值小于实际所需打开的文件数。解决方案包括调整非root用户限额、确保root用户下open_files_limit配置满足需求以及检查系统最大文件数(file-max)。同时,给出了相应配置修改建议和命令行选项传递方法。
最低0.47元/天 解锁文章
773

被折叠的 条评论
为什么被折叠?



