{{ item.name }}
{return false}">
{{ it.name }}
{{ it.text }}
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 theio_setup system call for all currently active aio contexts. If aio-nrreaches aio-max-nr then io_setup will fail with EAGAIN. Note thatraising aio-max-nr does not result in the pre-allocation or re-sizingof 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
其分配256 event的也就是 InnoDB IO线程
结论
实例申请的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