mysql-5.7 Using Asynchronous I/O on Linux

Posted 蒋乐兴的技术随笔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql-5.7 Using Asynchronous I/O on Linux相关的知识,希望对你有一定的参考价值。

一、mysql - innodb 使用异步IO的场景

  总的来说innodb 只会对数据文件采用异步IO,为了保存日志是真正被写入到磁盘,innodb不会对日志文件启用异步IO

  更新细一步的说,innodb只会对数据文件的read-ahead ,write 这两个操作启用异步IO

 

二、异步IO在mysql中解决了什么问题:

  在没有IO这个功能之前,innodb对数据的读写请求先放入任务队列,后台read-thread ,write-thread从任务队列中

  拿出任务并执行读写操作;后台读写线程的个数可以通过show engine innodb status 语句来查看

show engine innodb status;

--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/os:, sync i/os:
Pending flushes (fsync) log: 0; buffer pool: 0
376 OS file reads, 54 OS file writes, 7 OS fsyncs
41.77 reads/s, 21886 avg bytes/read, 6.00 writes/s, 0.78 fsyncs/s

  由上面的内容可以看出默认情况下innodb会有4个read-thread 和4个write-thread ,问题就出现在这里,如果业务繁重,那么

  读写任务就会非常的多,而innodb只有八个读写线程,这样的话队列中的其它读写请求就没能得到及时的响应。

  

  引入异步IO之后就变天啦,读写请求不再像之前那样先放入队列,等着后台的读写线程去执行任务;

 

 

----

以上是关于mysql-5.7 Using Asynchronous I/O on Linux的主要内容,如果未能解决你的问题,请参考以下文章

mysql 5.7 版本 You must reset your password using ALTER USER statement before executing this statement

Mac 安装 MySQL 5.7 后登入后无法执行命令You must reset your password using ALTER USER statement before executing

Mac 安装 MySQL 5.7 后登入后无法执行命令You must reset your password using ALTER USER statement before executing

mysql 5.7密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before exe

Mysql 5.7ERROR 1820 (HY000): You must reset your password using ALTER USER statement before execut(代

MySQL 5.7的多源复制