Linux的异步IO(AIO)在Oracle中应用

一直知道异步IO的存在,未有深入研究已经和测试过,偶然搜索到一些技术博主的文章,发现文章写的比较齐全,就大概整理了一下文章,并做了简单的测试来共享,如果你的系统遇到写问题或者想改善一下IO的效率,可以考虑一下异步IO的使用,尤其对使用裸设备的提升最为明显。

介绍:Linux 异步 I/O 是 Linux 内核中提供的一个相当新的增强。它是 2.6 版本内核的一个标准特性,但是我们在 2.4 版本内核的补丁中也可以找到它。AIO 背后的基本思想是允许进程发起很多 I/O 操作,而不用阻塞或等待任何操 作完成。稍后或在接收到 I/O 操作完成的通知时,进程就可以检索 I/O 操作的结果。

效果:使用异步 I/O 大大提高应用程序的性能.
AIO =  asynchronous IO

1、检查linux相关包
[root@anpc ~]# rpm -qa | grep aio
libaio-devel-0.3.106-3.2
libaio-0.3.106-3.2
libaio-devel-0.3.106-3.2
libaio-0.3.106-3.2
libsane-hpaio-1.6.7-4.1.el5_2.4
[root@anpc ~]# cat /proc/slabinfo | grep kio
kioctx                64     96    320   12    1 : tunables   54   27    8 : slabdata      8      8      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0

kiocb值的第二列和第三列非0即是已使用。
The kioctx and kiocb are Async I/O data structures that are defined in aio.h.
If it shows a non zero value that means async io is enabled.
source code loaded /usr/src/linux-<version>/include/linux/aio.h

从2.6 kernel开始,已经取消了对IO size的限制,Oracle建议将aio-max-nr的值设置为1048576或更高。
[root@anpc ~]# echo 1048576 > /proc/sys/fs/aio-max-nr

2、检查Oracle软件是否开启AIO支持。

[oracle@anpc ~]$ /usr/bin/ldd $ORACLE_HOME/bin/oracle | grep libaio
libaio.so.1 => /usr/lib64/libaio.so.1 (0x00002aaaac4a9000)
如上面
显示 说明已经开启
[oracle@anpc ~]$ /usr/bin/nm $ORACLE_HOME/bin/oracle | grep io_getevent
w io_getevents@@LIBAIO_0.4 
如上面 显示 说明已经开启

10GR1以前版本需要手动开启AIO,relink一下。
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk async_on
make -f ins_rdbms.mk ioracle

关闭Oracle的异步功能支持
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk async_off

3、开启Oracle数据库AIO功能的支持。

SQL> alter system set filesystemio_options = setall scope=spfile;

SQL> alter system set disk_asynch_io = true scope=spfile;

SQL> shutdown immediate

SQL> startup
4、查看是否开启

[root@anpc ~]# cat /proc/slabinfo | grep kio
kioctx                64     96    320   12    1 : tunables   54   27    8 : slabdata      8      8      0
kiocb                 15     15    256   15    1 : tunables  120   60    8 : slabdata      1      1      0
非零说明已经开启
5、速度测试
[oracle@anpc ~]$ sqlplus / as sysdba

SQL> select count(*) from test01;
 COUNT(*)
----------
   8388608
SQL> set timing on
SQL> create table test03 as select * from test01;
Table created.
Elapsed: 00:00:09.81

以前消耗的时间:
SQL> set timing on
SQL> create table test02 as select * from test01;
Table created.
Elapsed: 00:00:12.33
比较与更改前创建表的消耗时间缩短了有3秒。
至此完成测试以及调整。
E文说明:
Asynchronous I/O
With synchronous I/O, when an I/O request is submitted to the operating system,
the writing process blocks until the write is confirmed as complete. It can then continue processing.
With asynchronous I/O, processing continues while the I/O request is submitted and processed.
Use asynchronous I/O when possible to avoid bottlenecks.
Some platforms support asynchronous I/O by default, others need special configuration,
and some only support asynchronous I/O for certain underlying file system types.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值