linux mysql 开启异步io_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 (insertbuffer thread)

I/O thread 1 state: waiting for i/o request (logthread)

I/O thread 2 state: waiting for i/o request (readthread)

I/O thread 3 state: waiting for i/o request (readthread)

I/O thread 4 state: waiting for i/o request (readthread)

I/O thread 5 state: waiting for i/o request (readthread)

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/o's:, sync i/o's:

Pending flushes (fsync)log: 0; buffer pool: 0

376 OS file reads, 54 OS file writes, 7OS fsyncs41.77 reads/s, 21886 avg bytes/read, 6.00 writes/s, 0.78 fsyncs/s

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

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

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

请求,这样一来冲破了读写线程个数的硬性限制,二来由于异步IO是否阻塞的这也进一步提高了性能。

三、怎么启用mysql异步IO:

在linux系统下的mysql版本默认是开启异步IO的,当然啦也可以在配置文件中明确的指定启用异步IO

[mysqld]innodb_use_native_aio=ON

四、说了这么多异步IO的优点,难道它就这么完美吗:

启用异步IO之后,由于每一个查询线程都能发起IO请求,不在经由后台的读写线程;也就是说在启用异步IO

的情况下相当于是我们把IO的控制权交出去了。

----

交流学习&打赏

36fc14a27a2525cf2beaf454c66f50d4.png

fe5945426c85ce0bd9457b347fb47e5f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"/pkg/qct/software/llvm/release/arm/14.0.0/bin/clang" -g -Os -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -c -include AutoGen.h -mlittle-endian -fno-short-enums -save-temps -fverbose-asm -funsigned-char -ffunction-sections -fdata-sections -fno-builtin -Wno-address -fno-asynchronous-unwind-tables -target aarch64-linux-gnu -fcolor-diagnostics -fdiagnostics-format=vi -Wno-parentheses-equality -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty-body -Wno-unknown-warning-option -Wno-unused-function -Wno-bitwise-op-parentheses -mcmodel=small -ffixed-x18 -mstrict-align -fstack-protector -Wno-nonportable-include-path -Wno-misleading-indentation -fno-common -mtune=cortex-a53 -I/home/chen-docker/bin/boot/boot_images/BuildLogs/QcomPkg/SocPkg/LeMans/AU/Include -include /home/chen-docker/bin/boot/boot_images/boot/QcomPkg/Include/Library/DebugLib.h -DQCOM_EDK2_PATCH -DDISABLE_DEP -DENABLE_XN -DENABLE_ASLR -DENABLE_DEP_64 -DENABLE_EXEC_CODE_READY_TO_BOOT -DENABLE_AUTO_PLAT -DMAX_DDR_REGIONS=6 -mstrict-align -mcpu=cortex-a53 -DPRODMODE -c -o /home/chen-docker/bin/boot/boot_images/Build/LeMansAU/Core/RELEASE_CLANG140LINUX/AARCH64/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib/OUTPUT/./HiiLib.obj @/home/chen-docker/bin/boot/boot_images/Build/LeMansAU/Core/RELEASE_CLANG140LINUX/AARCH64/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib/OUTPUT/inc.lst /home/chen-docker/bin/boot/boot_images/edk2/MdeModulePkg/Library/UefiHiiLib/HiiLib.c /pkg/qct/software/llvm/release/arm/14.0.0/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory GNUmakefile:373: recipe for target '/home/chen-docker/bin/boot/boot_images/Build/LeMansAU/Core/RELEASE_CLANG140LINUX/AARCH64/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib/OUTPUT/HiiLib.obj' failed Building ... /home/chen-docker/bin/boot/boot_images/edk2/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf [AARCH64] make: *** [/home/chen-docker/bin/boot/boot_images/Build/LeMansAU/Core/RELEASE_CLANG140LINUX/AARCH64/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib/OUTPUT/HiiLib.obj] Error 127 make: Nothing to be done for 'tbuild'. build.py... : error 7000: Failed to execute command make tbuild [/home/chen-docker/bin/boot/boot_images/Build/LeMansAU/Core/RELEASE_CLANG140LINUX/AARCH64/MdeModulePkg/Library/UefiHiiLib/UefiHiiLib]错误在哪里?
最新发布
07-20

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值