[20181219]測試設定引數filesystemio_options與開啟資料檔案的flag.txt

lfree發表於2018-12-19

[20181219]測試設定引數filesystemio_options與開啟資料檔案的flag.txt


--//測試一下設定引數filesystemio_options,oracle資料庫開啟資料檔案以及線上日誌的flag.


1.環境:


SYS@book> @ ver1

PORT_STRING                    VERSION        BANNER

------------------------------ -------------- --------------------------------------------------------------------------------

x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production


SYS@book> create pfile='/tmp/@.ora' from spfile ;

File created.


SYS@book> @ spid

       SID    SERIAL# PROCESS SERVER    SPID       PID  P_SERIAL# C50

---------- ---------- ------- --------- ------ ------- ---------- --------------------------------------------------

       274          3 62448   DEDICATED 62496       21          2 alter system kill session '274,3' immediate;

--//啟動sqlplus的程式號是62448.下面的測試不要退出sqlplus.這樣sqlplus程式號不會變.


$ ps -ef |grep 6244[8]

oracle   62448 62447  0 15:51 pts/2    00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/sqlplus   as sysdba

oracle   62496 62448  0 15:51 ?        00:00:00 oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))


2.測試一:

--//filesystemio_options=none的情況.也是預設設定.

--//關閉重新啟動資料庫,為了顯示方便,啟動可以分2步,先啟動到mount,在執行alter database open.以下測試除了filesystemio_options不同外,

--//其它步驟一樣.

SYS@book> startup mount pfile='/tmp/book.ora';

ORACLE instance started.

Total System Global Area  643084288 bytes

Fixed Size                  2255872 bytes

Variable Size             205521920 bytes

Database Buffers          427819008 bytes

Redo Buffers                7487488 bytes

Database mounted.


SYS@book> alter database open ;

Database altered.


SYS@book> show parameter filesystemio_options

NAME                 TYPE   VALUE

-------------------- ------ ------

filesystemio_options string NONE


--//開啟新終端,執行如下,一個小細節注意-f在-p引數前面才有效:

$ strace -tt -f -p 62448 -e open 2>&1 | tee /tmp/none.txt

[pid 63083] 16:12:16.425620 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 9


$ grep "ramdisk" /tmp/none.txt | egrep "system|sysaux|redo|control|users" | cut -c29- | sort | uniq -c

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY <unfinished ...>

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 10

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 12

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 14

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 9

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC <unfinished ...>

      4 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY) = 11

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 10

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 12

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 14

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 9

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC <unfinished ...>

      2 open("/mnt/ramdisk/book/redo01.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo01.log", O_RDWR|O_SYNC) = 11

      2 open("/mnt/ramdisk/book/redo02.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDWR|O_SYNC) = 11

      2 open("/mnt/ramdisk/book/redo03.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDWR|O_SYNC) = 11

      2 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY) = 11

      4 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 14

      7 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 9

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY) = 11

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 12

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 14

      6 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 9

      5 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC <unfinished ...>

      2 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY) = 11

      4 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC) = 9


--//可以發現filesystemio_options=none的情況下,開啟flag都包含O_SYNC標誌.


3.測試二:

--//設定filesystemio_options=asynch.

$ strace -tt -f -p 62448 -e open 2>&1 | tee /tmp/asynch.txt

$ grep "ramdisk" /tmp/asynch.txt | egrep "system|sysaux|redo|control|users" | cut -c29- | sort | uniq -c

      4 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY) = 11

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 10

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 12

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 14

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC) = 9

      4 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY) = 11

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 10

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 12

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 14

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC) = 9

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLY <unfinished ...>

      1 open("/mnt/ramdisk/book/redo01.log", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY <unfinished ...>

      1 open("/mnt/ramdisk/book/redo02.log", O_RDWR|O_SYNC <unfinished ...>

      2 open("/mnt/ramdisk/book/redo03.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDWR|O_SYNC) = 11

      2 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY) = 11

      4 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 14

      5 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC) = 9

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 10

      3 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 11

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 14

      4 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC) = 9

      3 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC <unfinished ...>

      2 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY) = 11

      4 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC) = 11

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC) = 9

--//可以發現filesystemio_options=asynch的情況下,開啟flag都包含O_SYNC標誌.


4.測試三:

--//設定filesystemio_options=directio.

$ strace -tt -f -p 62448 -e open 2>&1 | tee /tmp/direct.txt


$ grep "ramdisk" /tmp/direct.txt | egrep "system|sysaux|redo|control|users" | cut -c29- | sort | uniq -c

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY) = 11

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY|O_DIRECT) = 11

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 10

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 12

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 14

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY) = 11

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY|O_DIRECT) = 11

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 10

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 12

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 14

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLY|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo01.log", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY <unfinished ...>

      1 open("/mnt/ramdisk/book/redo02.log", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/redo03.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDONLY|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY|O_DIRECT) = 11

      4 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 14

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY|O_DIRECT) = 11

      3 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 14

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY|O_DIRECT) = 11

      4 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

--//可以發現filesystemio_options=directio的情況下,開啟flag都包含O_SYNC,O_DIRECT標誌.


5.測試四:

--//設定filesystemio_options=setall

$ strace -tt -f -p 62448 -e open 2>&1 | tee /tmp/setall.txt


$ grep "ramdisk" /tmp/setall.txt | egrep "system|sysaux|redo|control|users" | cut -c29- | sort | uniq -c

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY) = 11

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDONLY <unfinished ...>

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 10

      2 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 12

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 14

      3 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/control01.ctl", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY) = 11

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDONLY|O_DIRECT) = 11

      2 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 10

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 12

      1 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 14

      3 open("/mnt/ramdisk/book/control02.ctl", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLY|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/redo01.log", O_RDONLYProcess 63595 detached

      1 open("/mnt/ramdisk/book/redo01.log", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/redo02.log", O_RDONLY <unfinished ...>

      1 open("/mnt/ramdisk/book/redo02.log", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/redo03.log", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDONLY|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/redo03.log", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDONLY|O_DIRECT) = 11

      3 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 14

      5 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/sysaux01.dbf", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/system01.dbf", O_RDONLY|O_DIRECT) = 11

      3 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 14

      5 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 9

      2 open("/mnt/ramdisk/book/system01.dbf", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY) = 11

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDONLY|O_DIRECT) = 11

      3 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 11

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 9

      1 open("/mnt/ramdisk/book/users01.dbf", O_RDWR|O_SYNC|O_DIRECT <unfinished ...>

--//可以發現filesystemio_options=directio的情況下,開啟flag都包含O_SYNC,O_DIRECT標誌.


--//可以看出oracle支援設定非同步IO,開啟flag也是設定O_SYNC.

--//如果filesystemio_options=directio,setall,都設定O_DIRECT標識.只不過direct不支援非同步IO.setall支援非同步IO罷了.


--//貼man open手冊:

NAME

       open, creat - open and possibly create a file or device


SYNOPSIS

       #include <sys/types.h>

       #include <sys/stat.h>

       #include <fcntl.h>


       int open(const char *pathname, int flags);

       int open(const char *pathname, int flags, mode_t mode);

       int creat(const char *pathname, mode_t mode);


DESCRIPTION


      O_DIRECT

 Try to minimize cache effects of the I/O to and from this file.  In general this will degrade performance, but it

 is useful in special situations, such as when applications do their own caching.  File I/O is done directly

 to/from user  space  buffers.   The I/O is synchronous, i.e., at the completion of a read(2) or write(2), data is

 guaranteed to have been transferred.  Under Linux 2.4 transfer sizes, and the alignment of user buffer and file

 offset must all be multiples of the logical block size of the file system. Under Linux 2.6 alignment must fit the

 block size of the device.


 O_SYNC The file is opened for synchronous I/O. Any write()s on the resulting file descriptor will block the

 calling process until the data has been physically written to the underlying hardware.  But see RESTRICTIONS

 below.


--//也就是write操作是使用同步IO,這樣保證更改寫操作同時更新到磁碟,避免資料庫損壞資訊丟失.

--//不過許多儲存,磁碟都有快取,寫了未必"真正"寫到磁碟上,掉電等一些因為很容易導致資料庫損壞,特別是繁忙的系統的線上日誌.

--//我發現許多人喜歡設定filesystemio_options=setall,我們系統一般使用nfs做為備份,設定這個引數恢復有問題,我的測試庫.

--//建立記憶體盤裡面的(注:當前測試不是,我移動到磁碟上了).設定filesystemio_options=setall,direct.資料庫無法開啟,報

ORA-205 signalled during: ALTER DATABASE   MOUNT...


--//連結:

http://blog.itpub.net/267265/viewspace-2147530/

http://blog.itpub.net/267265/viewspace-2122164/


--//我個人認為設定filesystemio_options=asynch,這樣可以充分利用os的快取,當然也可能掩蓋資料庫的一些問題.

--//如果看一些rac+asm的系統,因為無法使用os快取,IO相對繁忙的系統log file sync相對靠前,Wait Avg(ms)達到10ms以上,

--//基本說明儲存效能很差或者規劃不合理.

--//當然設定filesystemio_options=setall可以空出更多的記憶體給sga,應用程式使用.我個人估計連線數很大消耗pga很大的一些

--//應用設定它,也許效果好一些,沒有相關測試,只能是自己的猜測.


-//oracle官方的解析:

9.1.1.2 FILESYSTEMIO_OPTIONS Initialization Parameter


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.


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. 

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.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2285785/,如需轉載,請註明出處,否則將追究法律責任。

相關文章