一、Oracle在Linux下使用异步IO配置 

 

最近在测试Oracle的时候,很想测试下使用异步IO的性能。但是异步IO是需要专门配置的,否则的话,容易遇到很著名的“ORA-01578: ORACLE data block corrupted (file # 202, block # 257)”的问题。

那么什么是异步IO呢,异步IO有什么好处?

一般说来,异步I/O是和同步I/O相比较来说的,如果是同步I/O,当一个I/O操作执行时,应用程序必须等待,直到此I/O执行完. 相反,异步I/O操作在后台运行,I/O操作和应用程序可以同时运行,提高了系统性能; 使用异步I/O会提高I/O流量,如果应用是对裸设备进行操作,这种优势更加明显, 因此象数据库,文件服务器等应用往往会利用异步I/O,使得多个I/O操作同时执行.

Oracle在默认情况是不使用异步IO的。可查看参数filesystemio_options(默认值为none),有四种选项

■ ASYNCH: enable asynchronous I/O on file system files, which has no timing requirement for transmission.
■ DIRECTIO: enable direct I/O on file system files, which bypasses the buffer cache.
■ SETALL: enable both asynchronous and direct I/O on file system files.
■ NONE: disable both asynchronous and direct I/O on file system files.

 

Oracle : 11.2.0.0.0

Linux:debian  2.6.18-6-amd64

具体步骤如下:

1、首先用root用户安装以下必要的包

# aptitude search libaio
i   libaio-dev                                     - Linux kernel AIO access library - development files                                                      
i   libaio1                                           - Linux kernel AIO access library - shared library  

# aptitude install  libaio1 libaio-dev

2、在系统级支持异步I/O

Oracle建议将aio-max-nr的值设置为1048576或更高。

# echo > /proc/sys/fs/aio-max-nr 1048576

3、在数据库级启用异步I/O

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

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

SQL>shutdown immediate

$ cd $ORACLE_HOME/rdbms/lib
$ ln -s /usr/lib/libaio.so.1 skgaio.o
$ make PL_ORALIBS=-laio -f ins_rdbms.mk async_on

SQL>startup

4、检查异步I/O是否在使用

    用以下命令即可检查异步IO是否在使用,kiocb的值不为0即是已使用。与kernel 2.4.x不同,没有显示kiobuf,因为从kernel 2.5.43开始,kiobuf已经从内核中被移除。

$ cat /proc/slabinfo | grep kio 
kioctx 64 110 384 10 1 : tunables 54 27 8 : slabdata 11 11 0 
kiocb 13 315 256 15 1 : tunables 120 60 8 : slabdata 21 21 44

二、Oracle异步IO缺点

异步io可能会导致坏块,所以没有dg情况下,最好禁用
在有db_file_parallel_wait等待高的情况下,可以试着禁用异步io
在异步io性能不如同步io的情况下,关闭异步io,可以调大dbwriter_processes,使用dbwr_io_slaves 
sga小的情况下,也不适合设置setall
redhat6上的ext4上设置改参数setall可能会有问题
https://access.redhat.com/solutions/519883
disk_asynch_io是相当于主开关,不管是文件系统还是raw,控制着异步io的开启与关闭,filesystemio_options是子开关,控制着文件系统上的异步io。所以如果你的库只用了文件系统,那么异步io只是受filesystemio_options控制。
 
整理自:
https://blog.csdn.net/aoerqileng/article/details/78738353
https://blog.csdn.net/yongjiao124/article/details/51239735
 posted on 2019-11-11 14:41  xibuhaohao  阅读(971)  评论(0编辑  收藏  举报