環境
系統: centos7.7
docker: 19
mysql: 8.0.18
將原網址變更為
報錯分析
日志內容
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
問題分析
看到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個)
在/etc/sysctl.conf
fs.aio-max-nr=262144 #(256k個)
執行命令使其生效
sysctl -p
可以看到/proc/sys/fs/aio-max-nr中的值發生了變化
cat /proc/sys/fs/aio-max-nr
重啟MySQL實例