InnoDB: Error: io_setup() failed with EAGAIN after 5 attempt

php中文网
发布: 2016-06-07 16:50:34
原创
1589人浏览过

在一台服务器中以各数据库的备份文件为数据文件启动多个MySQL实例供SQL Review使用。之前运行一直没有问题(最多的时候有23个MyS

在一台服务器中以各数据库的备份文件为数据文件启动多个mysql实例供sql review使用。
之前运行一直没有问题(最多的时候有23个mysql实例同时运行),后来新配置了一台服务器,启动其对应的实例时失败。

部分错误日志如下:
……
140505 16:05:59 innodb: using linux native aio
140505 16:05:59 innodb: warning: io_setup() failed with eagain. will make 5 attempts before giving up.
innodb: warning: io_setup() attempt 1 failed.
innodb: warning: io_setup() attempt 2 failed.
innodb: warning: io_setup() attempt 3 failed.
innodb: warning: io_setup() attempt 4 failed.
innodb: warning: io_setup() attempt 5 failed.
140505 16:06:02 innodb: error: io_setup() failed with eagain after 5 attempts.
innodb: you can disable linux native aio by setting innodb_use_native_aio = 0 in my.cnf
140505 16:06:02 innodb: fatal error: cannot initialize aio sub-system
140505 16:06:02 [error] plugin 'innodb' init function returned error.
140505 16:06:02 [error] plugin 'innodb' registration as a storage engine failed.
140505 16:06:02 [error] unknown/unsupported storage engine: innodb
……

通过错误日志了解到最早发生错误的地方为 innodb: error: io_setup() failed with eagain after 5 attempts。
这个io_setup() failed with eagain是关键。

我们man一下io_setup
name
io_setup - create an asynchronous i/o context
……
description
io_setup() creates an asynchronous i/o context capable of receiving at least maxevents. ctxp must not point to an aio context that already exists, and must be
initialized to 0
prior to the call. on successful creation of the aio context, *ctxp is filled in with the resulting handle.
return value
io_setup() returns 0 on success; otherwise, one of the errors listed in the "errors" section is returned.
errors
einval ctxp is not initialized, or the specified maxevents exceeds internal limits. maxevents should be greater than 0.
efault an invalid pointer is passed for ctxp.
enomem insufficient kernel resources are available.
eagain the specified maxevents exceeds the user’s limit of available events.
enosys io_setup() is not implemented on this architecture.
conforming to
……
看到io_setup用来创建异步i/o上下文环境用于特定目的,,错误代码eagain意为指定的maxevents 超出了用户可用events的限制。
该服务器上已经运行了较多的mysql实例,创建异步i/o的资源已经达到了临界,所以新的实例启动失败。

最后通过在启动mysql实例时加入 --innodb_use_native_aio = 0解决了问题。


也有通过更改系统设置来解决此问题的(待验证)。
cat /proc/sys/fs/aio-max-nr可以查看到当前的aio-max-nr的值一般为65536(64k个)

可通过下述步骤改变该文件中的值(上述文件不能直接编辑)
sudo vim /etc/sysctl.conf
修改或加入
fs.aio-max-nr=262144(256k个)

执行命令修改/proc/sys/fs/aio-max-nr
sysctl -p

可以看到/proc/sys/fs/aio-max-nr中的值发生了变化
cat /proc/sys/fs/aio-max-nr

重启mysql实例

还有通过修改mysql源码来避免该问题的,但一般情况下不推荐也没有必要这么做。

InnoDB存储引擎的启动、关闭与恢复

MySQL InnoDB独立表空间的配置

MySQL Server 层和 InnoDB 引擎层 体系结构图

Upscale
Upscale

AI图片放大工具

Upscale 85
查看详情 Upscale

InnoDB 死锁案例解析

MySQL Innodb独立表空间的配置

本文永久更新链接地址:

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号