Oracle 之 AIO (異步io)
採用文件系統存放數據庫文件,需要注意 AIO的配置。
Linux 異步 I/O (AIO)是 Linux 內核中提供的一個增強的功能。它是Linux 2.6 版本內核的一個標準特性,AIO 背後的基本思想是允許進程發起很多 I/O 操作,而不用阻塞或等待任何操作完成。稍後或在接收到 I/O 操作完成的通知時,進程就可以檢索 I/O 操作的結果。
同步IO:線程啓動一個IO操作然後就立即進入等待狀態,直到IO操作完成後才醒來繼續執行。
異步IO:線程發送一個IO請求到內核,然後繼續處理其他的事情,內核完成IO請求後,將會通知線程IO操作完成
補充:當後臺等待事件排在第一的是 db file async I/O submit,這是一個異步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
6、 數據庫層面查看是否開啓異步io
select name, asynch_io
from v$datafile f, v$iostat_file i
where f.file# = i.file_no
and (filetype_name = 'Data File' or filetype_name = 'Temp File');
來自;https://www.cnblogs.com/andy6/p/7492016.html、
============= AIO For AIX
步驟1--獲取CPU個數
# vmstat
步驟2—查看異步IO的配置
# ioo -F -a|grep aio
aio_active = 1
aio_maxreqs =4096 #最大請求數
aio_maxservers = 10 #每個cpu的aio的最大服務數
aio_minservers = 3 #每個cpu的aio的最小服務數
步驟3—查看異步IO的maxgc:
如果maxgc長時間處於超過CPU個數*aio_maxservers的狀態,則說明IO可能有嚴重性能問題,需要對異步IO配置做出調整!