在一台新的服务器上,部署多个MySQL实例时,在启动MySQL时报错
日志报错如下:
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.
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
InnoDB: Fatal error: cannot initialize AIO sub-system
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
通过error日志了解到发生错误的地方为 InnoDB: Error: io_setup() failed with EAGAIN after 5 attempts。
看到io_setup用来创建异步I/O上下文环境用于特定目的,错误代码EAGAIN意为指定的maxevents 超出了用户可用events的限制。
因为该服务器上已经运行了较多的MySQL实例,创建异步I/O的资源已经达到了临界,所以新的实例启动失败。
1、可以通过在启动MySQL实例时加入 --innodb_use_native_aio = 0解决了问题。
2、通过更改系统设置来解决此问题。
cat /proc/sys/fs/aio-max-nr
可以查看到当前的aio-max-nr的值一般为65536(64k个)
重启MySQL实例
这时MySQL就可以启动了O(∩_∩)O哈哈~
PS(清除系统缓存的方法:free -h 查看系统缓存;
cat /proc/sys/vm/drop_caches
0
echo 3 >/proc/sys/vm/drop_caches
cat /proc/sys/vm/drop_caches
3
free -h这时可以看到caches已经被清除了!)