fs.aio max nr mysql_技术分享 | MySQL 主机该如何配置 fs.aio-max-nr

b4915e9a23e19d07c74c4d597baac1df.png

MySQL 默认是启用 innodb_use_native_aio,使用异步 IO 操作,MySQL 启动时所需 aio slot 若超过系统当前 fs.aio-max-nr 设置,则无法启动报错 InnoDB: io_setup() failed with EAGAIN after 5 attempts.

通常在单机单实例环境下很少会遇到超出 aio-max-nr 的问题,若部署单机多实例,会大概率遇到此问题。我们来分析下该如何配置 fs.aio-max-nr 参数。关于 aio-nr 与 aio-max-nr

aio-nr is the running total of the number of events specified on the

io_setup system call for all currently active aio contexts. If aio-nr

reaches aio-max-nr then io_setup will fail with EAGAIN. Note that

raising aio-max-nr does not result in the pre-allocation or re-sizing

of any kernel data structures.

启动 MySQL 时会分配多少个 event slot?

使用 strace 观测 io_setup 调用情况,

strace -fe trace=io_setup /path/to/mysqld --defaults-file=/etc/my.cnf --daemonize 2>&1 |grep io_setup

总共:4709 个 =  18 * 256 + 101

up-7a047d325df508e651737e6363268fa4e02.JPEG

其分配 256 event 的也就是 InnoDB IO 线程。

up-7197fb9f06044c0993ac085c676a3d2d495.JPEG

结论

实例申请的 fs.aio-nr = (innodb_read_io_threads  + innodb_write_io_threads  + log thread + insert buffer thread)  * 256  + 101

若单实例部署,fs.aio-max-nr 至少大于单实例 fs.aio-nr

若多实例部署,至少大于 本机实例数 * 每个实例的 fs.aio-nr

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值