Oracle中AIO解析

Linux 异步 I/O (AIO)是 Linux 内核中提供的一个增强的功能。它是Linux 2.6 版本内核的一个标准特性,AIO 背后的基本思想是允许进程发起很多 I/O 操作,而不用阻塞或等待任何操作完成。稍后或在接收到 I/O 操作完成的通知时,进程就可以检索 I/O 操作的结果。

同步IO:线程启动一个IO操作然后就立即进入等待状态,直到IO操作完成后才醒来继续执行。
异步IO:线程发送一个IO请求到内核,然后继续处理其他的事情,内核完成IO请求后,将会通知线程IO操作完成

1、–查看系统是否使用异步IO 。 slab是Linux的内存分配器,AIO相关的内存结构已经分配。

more /proc/slabinfo |grep kio  [root@localhost ~]# grep kio /proc/slabinfo  kioctx 0 0 384 10 1 : tunables 54 27 0 : slabdata 0 0 0  kiocb 0 0 256 15 1 : tunables 120 60 0 : slabdata 0 0 0

看到kiocb行显示为0,说明异步IO没有启动。

2、 查看数据库是否开启异步io

(11G)SYS@qixindb> show parameter disk_asynch_io  NAME TYPE VALUE  ------------------------------------ ----------- ------------------------------  disk_asynch_io boolean TRUE  (11G)SYS@qixindb> show parameter filesystem  NAME TYPE VALUE  ------------------------------------ ----------- ------------------------------  filesystemio_options string none
filesystemio_options 的四种值:  ASYNCH: enable asynchronous I/O on file system files, which has no timing requirement for transmission.  在文件系统文件上启用异步I/O,在数据传送上没有计时要求。  DIRECTIO: enable direct I/O on file system files, which bypasses the buffer cache.  在文件系统文件上启用直接I/O,绕过buffer cache。  SETALL: enable both asynchronous and direct I/O on file system files.  在文件系统文件上启用异步和直接I/O。  NONE: disable both asynchronous and direct I/O on file system files.  在文件系统文件上禁用异步和直接I/O。

3、 oracle已经链接了aio的包

[oracle@localhost ~]$ /usr/bin/ldd $ORACLE_HOME/bin/oracle | grep libaio  libaio.so.1 => /lib64/libaio.so.1 (0x0000003e13000000)

说明:检查显示oracle已经链接了aio的包

4、 调整数据库参数 开启aio
数据库中的filesystemio_options参数设置为none,看来oracle中也没有配置异步IO,
这里可以将数据库中的filesystemio_options参数调整为setall;

SQL> alter system set filesystemio_options = setall scope=spfile;   SQL> alter system set disk_asynch_io = true scope=spfile;   SQL> shutdown immediate;  SQL> startup;

5、查看aio是否生效

[oracle@localhost ~]$ more /proc/slabinfo |grep kio  kioctx 130 160 384 10 1 : tunables 54 27 8 : slabdata 16 16 0  kiocb 16 30 256 15 1 : tunables 120 60 8 : slabdata 2 2 1

补充:出现 free buffer waits 等待事件 或者 io不给力的时候, 可以考虑开启aio。

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享