1. 程式人生 > >InnoDB: Error: io_setup() failed with EAGAIN after 5 attempts#Olivia丶長歌#

InnoDB: Error: io_setup() failed with EAGAIN after 5 attempts#Olivia丶長歌#

      在一臺新的伺服器上,部署多個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個)


可通過下述步驟改變該檔案中的值
vim /etc/sysctl.conf
修改或加入
fs.aio-max-nr=262144(256k個)

執行命令修改sysctl -p

可以看到/proc/sys/fs/aio-max-nr中的值發生了變化
cat /proc/sys/fs/aio-max-nr
可以看到aio-max-nr已經變成256k個

重啟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已經被清除了!)