成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

ORACLE數據庫異步IO介紹

數據庫 Oracle
Linux 異步 I/O (AIO)是 Linux 內核中提供的一個增強的功能。它是Linux 2.6 版本內核的一個標準特性,當然我們在2.4 版本內核的補丁中也可以找到它。AIO 背后的基本思想是允許進程發起很多 I/O 操作,而不用阻塞或等待任何操作完成。稍后或在接收到 I/O 操作完成的通知時,進程就可以檢索 I/O 操作的結果。

   異步IO概念

  Linux 異步 I/O (AIO)是 Linux 內核中提供的一個增強的功能。它是Linux 2.6 版本內核的一個標準特性,當然我們在2.4 版本內核的補丁中也可以找到它。AIO 背后的基本思想是允許進程發起很多 I/O 操作,而不用阻塞或等待任何操作完成。稍后或在接收到 I/O 操作完成的通知時,進程就可以檢索 I/O 操作的結果。

  Linux IO模型(I/O models)分同步IO模型(synchronous models)和異步IO模型(asynchronous models)。 在同步IO中,線程啟動一個IO操作然后就立即進入等待狀態,直到IO操作完成后才醒來繼續執行。而異步IO方式中,線程發送一個IO請求到內核,然后繼 續處理其他的事情,內核完成IO請求后,將會通知線程IO操作完成了

  如果IO請求需要大量時間執行的話,異步文件IO方式可以顯著提高效率,因為在線程等待 的這段時間內,CPU將會調度其他線程進行執行,如果沒有其他線程需要執行的話,這段時間將會浪費掉(可能會調度操作系統的零頁線程)。如果IO請求操作 很快,用異步IO方式反而還低效,還不如用同步IO方式。

  其它關于異步IO與同步IO的細節,可以參考Boost application performance using asynchronous I/O這篇文章,網上很多"Linux異步IO"的文章其實是翻譯自這篇文章。如果了解更多關于異步IO的細節,可以細讀這篇文章。

  異步IO好處

  異步I/O的優點:異步I/O是和同步I/O相比較來說的,如果是同步I/O,當一個I /O操作執行時,應用程序必須等待,直到此I/O執行完。相反,異步I/O操作在后臺運行,I/O操作和應用程序可以同時運行,提高了系統性能;使用異步 I/O會提高I/O流量,如果應用是對裸設備進行操作,這種優勢更加明顯, 因此像數據庫,文件服務器等應用往往會利用異步I/O,使得多個I/O操作同時執行. 而且從官方文檔來看,ORACLE也是推薦ORACLE數據庫啟用異步IO的這個功能的。

  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.

  Q: 2. What are the benefits of Asynchronous I/O?

  A: The implementation of Asynchronous I/O on Red Hat Advanced Server allows Oracle processes to issue multiple I/O requests to disk with a single system call, rather than a large number of single I/O requests. This improves performance in two ways:

  First, because a process can queue multiple requests for the kernel to handle, so the kernel can optimize disk activity by recording requests or combining individual requests that are adjacent on disk into fewer and larger requests.

  Secondary, because the system does not put the process in sleep state while the hardware processes the request. So, the process is able to perform other tasks until the I/O complete.

  This involves making use of I/O capabilities such as:

  Asynchronous I/O: Asynchronous I/O does not reduce traffic but allows processes to do other things while waiting for IO to complete.

  Direct I/O (bypassing the Operating System's File Caches) : Direct IO does not reduce traffic but may use a shorter code path / fewer CPU cycles to perform the IO.

  啟用異步IO

  ORACLE數據庫是從ORACLE 9i Release 2開始支持異步IO特性的。之前的版本是不支持異步IO特征的。另外在ORACLE 9i R2和 ORACLE 10g R1中默認是禁用異步特性的,直到ORACLE 10g R2才默認啟用異步IO特性。

  Q: 4. Can I use Asynchronous I/O with Oracle 8i or Oracle 9i release 1?

  A: No. Asynchronous I/O feature is only available with Oracle RDBMS 9i release 2 (Oracle9iR2).

  Q: 5. Is Asynchronous I/O active with Oracle RDBMS by default?

  A: No. By default, Oracle9iR2 and Oracle10gR1 are shipped with asynchronous I/O support disabled.In 10gR2 asyncIO is enabled by default.

  那么如何啟用ORACLE數據庫的異步IO特性呢? 我們可以按照下面步驟操作:

  1:首先要確認ORACLE數據庫所在的系統平臺(操作系統)是否支持異步IO

  目前流行的Linux/Unix平臺基本上都支持異步IO,但是一些老舊的版本就不一定了??梢运阉饕幌孪嚓P文檔了解清楚。

  2: 檢查是否安裝libaio、libaio-devel相關包(似乎libaio-devel包不是必須的,測試環境沒有libaio-devel似乎也OK,當然最好也一起安裝)

 

  1. [root@DB-Server ~]# rpm -qa | grep aio  
  2. libaio-0.3.106-5 
  3. libaio-0.3.106-5 
  4.   
  5. [root@DB-Server Server]# rpm -ivh libaio-devel-0.3.106-5.i386.rpm 
  6. warning: libaio-devel-0.3.106-5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159 
  7. Preparing...                ########################################### [100%] 
  8.    1:libaio-devel           ########################################### [100%] 
  9. [root@DB-Server Server]# rpm -ivh  libaio-devel-0.3.106-5.x86_64.rpm 
  10. warning: libaio-devel-0.3.106-5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159 
  11. Preparing...                ########################################### [100%] 
  12.    1:libaio-devel           ########################################### [100%] 
  13.   
  14. [root@DB-Server Server]# rpm -qa | grep libaio 
  15. libaio-0.3.106-5 
  16. libaio-devel-0.3.106-5 
  17. libaio-devel-0.3.106-5 
  18. libaio-0.3.106-5 

 

  3:檢查系統是否支持異步I/O

  根據文檔[Note 370579.1] ,可以通過查看slabinfo統計信息查看操作系統中AIO是否運行,slab是Linux的內存分配器,AIO相關的內存結構已經分配,kiocb值的第二列和第三列非0即是已使用

  [root@DB-Server ~]# cat /proc/slabinfo | grep kio

  kioctx 62 110 384 10 1 : tunables 54 27 8 : slabdata 11 11 0

  kiocb 0 0 256 15 1 : tunables 120 60 8 : slabdata 0 0 0

  kiocb值的第二列和第三列非0表示系統已經啟用異步IO。如上所示,表示異步I/O沒有在使用。

  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-/include/linux/aio.h

  4:修改、優化系統內核參數

  Linux從2.6 kernel開始,已經取消了對IO size的限制,Oracle建議將aio-max-nr的值設置為1048576或更高。

  [root@DB-Server ~]# cat /proc/sys/fs/aio-max-nr

  65536

  命令echo 1048576 > /proc/sys/fs/aio-max-nr修改參數,只對當前環境有效,如果系統重啟過后,則會使用默認值,所以最好修改參數文件/etc /sysctl.conf。編輯/etc/sysctl.conf 添加或修改參數fs.aio-max-nr = 1048576,保存后。運行sysctl -p使之生效。

 

 

  [root@DB-Serveruat ~]# cat /proc/sys/fs/aio-max-nr

  1048576

  注意aio-max-size參數從RHEL4開始已經不存在了,詳情見文檔Kernel Parameter "aio-max-size" does not exist in RHEL4 / EL4 / RHEL5 /EL5 (文檔 ID 549075.1)。

  5:檢查ORACLE軟件是否支持開啟AIO。

  如下所示有輸出值,表示ORACLE軟件支持開啟AIO,其實從ORACLE 9i R2開始,ORACLE就已經支持開啟異步IO(AIO)了。不過10GR1以前版本需要手動開啟AIO,相對而言要麻煩一些。

  1. [oracle@DB-Server ~]$ /usr/bin/ldd $ORACLE_HOME/bin/oracle | grep libaio 
  2.         libaio.so.1 => /usr/lib64/libaio.so.1 (0x00007f5a247f4000) 
  3. [oracle@DB-Server ~]$  /usr/bin/nm $ORACLE_HOME/bin/oracle | grep io_getevent  
  4.                  w io_getevents@@LIBAIO_0.4  

  6:數據庫級別啟用異步I/O

  將參數disk_asynch_io設置為true,其實ORACLE 10g R2中參數disk_asynch_io默認是為true的。

 

 

  1. SQL> alter system set filesystemio_options = setall scope=spfile;  
  2.   
  3. System altered. 
  4.   
  5. SQL> alter system set disk_asynch_io = true scope=spfile;  
  6.   
  7. System altered.

  關于參數filesystemio_options有四個值: asynch、directio, setall,none. 一般建議設置為setall比較合適。

  You can use the FILESYSTEMIO_OPTIONS initialization parameter to enable or disable asynchronous I/O or direct I/O on file system files. This parameter is platform-specific and has a default value that is best for a particular platform. It can be dynamically changed to update the default setting.

  FILESYTEMIO_OPTIONS can be set to one of the following values:

  · 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。

  設置完成后重啟數據庫,驗證異步IO特性是否啟用。如下所示, kiocb的第二、三列都不為0,表示ORACLE的異步IO特性已經啟用。

  [oracle@DB-Server ~]$ cat /proc/slabinfo | grep kio

  kioctx 60 80 384 10 1 : tunables 54 27 8 : slabdata 8 8 0

  kiocb 6 30 256 15 1 : tunables 120 60 8 : slabdata 2 2 0

  [oracle@DB-Server ~]$

  參考資料:

  http://www.ibm.com/developerworks/linux/library/l-async/index.html

  https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=73665184034240&parent=DOCUMENT&sourceId=223117.1&id=432854.1&_afrWindowMode=0&_adf.ctrl-state=11m9r3dm4l_242

  https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=73689176803264&parent=DOCUMENT&sourceId=471846.1&id=225751.1&_afrWindowMode=0&_adf.ctrl-state=11m9r3dm4l_291

  http://blog.sina.com.cn/s/blog_465a4a1e0100oizv.html

  http://semiter.blog.51cto.com/1234477/1243325

  本文轉自:http://www.cnblogs.com/kerrycode/

  作者:瀟湘隱者

  本文版權歸作者所有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接.

 

 

責任編輯:honglu 來源: 博客園
相關推薦

2015-10-28 14:45:35

ORACLE AIO異步IO

2011-05-17 13:43:23

Oracle數據庫

2010-03-18 09:28:14

Oracle數據庫遷移

2009-08-24 18:09:13

C#調用Oracle數

2010-04-15 13:01:25

Oracel數據庫

2010-05-07 17:39:02

Oracle數據庫性能

2010-04-02 12:23:30

Oracle數據庫

2010-04-20 11:41:55

Oracle數據庫

2010-04-23 14:32:01

Oracle數據庫

2011-07-27 11:08:49

Oracle數據庫EM Console重

2011-03-22 14:49:35

Oracle數據庫重定義表

2010-04-23 16:05:50

Oracle數據庫

2011-05-25 10:56:19

Oracle數據庫Unix環境優化

2010-04-07 09:31:02

Oracle數據庫

2010-04-19 12:16:53

Oracle數據庫

2011-08-11 16:08:55

Oracle數據庫ASHAWR

2011-09-02 10:37:15

Oraclesqlload用法

2010-04-15 15:42:11

Oracle數據庫

2011-08-05 13:17:34

Oracle數據庫閃回個性

2010-04-23 09:23:44

Oracle 數據庫
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产日韩欧美一区 | 亚洲成人免费视频在线 | 国产一区亚洲 | 五月婷六月丁香 | 中文字幕一区在线观看视频 | www97影院| 97伊人| 国产在线视频一区二区 | 亚洲国产成人久久久 | 超碰成人免费观看 | 免费一级黄 | 二区久久 | 你懂的av | 精品国产乱码久久久久久图片 | 国产一区二区a | 国产91久久精品一区二区 | 日韩午夜 | 精品日韩在线 | 亚洲国产成人精品女人久久久 | 欧美日一区二区 | 91在线视频国产 | 国产91久久精品一区二区 | 日日夜夜精品免费视频 | 国产伦精品一区二区三区精品视频 | jlzzjlzz国产精品久久 | 成人在线中文字幕 | 高清一区二区三区 | 国产亚洲精品精品国产亚洲综合 | 成人午夜影院 | 暴草美女 | 久久久亚洲一区 | 美女操网站 | 亚洲国产精品久久久久 | 亚洲精品久久久久久久不卡四虎 | 一级毛片视频在线 | 波多野结衣av中文字幕 | 91佛爷在线观看 | 91久久久久久久久久久久久 | 日本天堂一区二区 | 久久久黄色 | 91在线视频在线观看 |