linux引數之/proc/sys/fs詳解

myownstars發表於2013-02-02

aio-max-nr/aio-nr

最大允許的aio請求數/當前aio請求數

2.6之前的版本還有aio-max-size,自2.6AIO成為Linux預設選項;

aio-max-nr設定過小oracle可能遭遇ORA-27090,網上有類似案例:

執行於exadata上的11203,最大支援8000資料庫連線,經常遭遇ORA-27090,經檢查其aio-max-nr設定為3145728,但aio-nr已經為3145726

作者使用systemtap除錯系統試圖找出aio請求消耗如此多的原因,

stap -ve '

global allocated, allocatedctx, freed

  

probe syscall.io_setup {

  allocatedctx[pid()] += maxevents; allocated[pid()]++;

  printf("%d AIO events requested by PID %d (%s)\n",

    maxevents, pid(), cmdline_str());

}

probe syscall.io_destroy {freed[pid()]++}

  

probe kprocess.exit {

  if (allocated[pid()]) {

     printf("PID %d exited\n", pid());

     delete allocated[pid()];

     delete allocatedctx[pid()];

     delete freed[pid()];

  }

}

  

probe end {

foreach (pid in allocated) {

   printf("PID %d allocated=%d allocated events=%d freed=%d\n",

      pid, allocated[pid], allocatedctx[pid], freed[pid]);

}

}

'

輸出結果如下

Pass 1: parsed user script. and 76 library script(s) using 147908virt/22876res/2992shr kb, in 130usr/10sys/146real ms.

Pass 2: analyzed script. 4 probe(s), 10 function(s), 3 embed(s), 4 global(s) using 283072virt/49864res/4052shr kb, in 450usr/140sys/586real ms.

Pass 3: using cached /root/.systemtap/cache/11/stap_111c870f2747cede20e6a0e2f0a1b1ae_6256.c

Pass 4: using cached /root/.systemtap/cache/11/stap_111c870f2747cede20e6a0e2f0a1b1ae_6256.ko

Pass 5: starting run.

128 AIO events requested by PID 32885 (oracledbm1 (LOCAL=NO))

4096 AIO events requested by PID 32885 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69099 (oracledbm1 (LOCAL=NO))

4096 AIO events requested by PID 69099 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69142 (oracledbm1 (LOCAL=NO))

4096 AIO events requested by PID 69142 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69099 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69142 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 32885 (oracledbm1 (LOCAL=NO))

4096 AIO events requested by PID 69142 (oracledbm1 (LOCAL=NO))

4096 AIO events requested by PID 69099 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69142 (oracledbm1 (LOCAL=NO))

128 AIO events requested by PID 69099 (oracledbm1 (LOCAL=NO))

...

(and when control-C is pressed):

  

PID 99043 allocated=6 allocatedevents=12672 freed=3

PID 37074 allocated=12 allocatedevents=25344 freed=6

PID 99039 allocated=18 allocatedevents=38016 freed=9

PID 69142 allocated=24 allocatedevents=50688 freed=12

PID 32885 allocated=36 allocatedevents=76032 freed=18

PID 69099 allocated=6 allocatedevents=12672 freed=3

 

Oracle程式佔用了大量的AIO,有些程式一次就請求4096,最後經oracle技術支援協商,將aio-max-nr設定為5000萬,自此ORA-27090再也沒有出現過

http://www.pythian.com/blog/troubleshooting-ora-27090-async-io-errors/

 

如何檢查系統是否使用AIO

justin_$ cat /proc/slabinfo | grep kio

kioctx               579    920    384   10    1 : tunables   54   27    8 : slabdata     92     92      1

kiocb                 35     45    256   15    1 : tunables  120   60    8 : slabdata      3      3      0

 

如何確定oracle是否連結了AIO

justin_$ /usr/bin/ldd $ORACLE_HOME/bin/oracle | grep libaio

        libaio.so.1 => /usr/lib64/libaio.so.1 (0x00007fca30cb4000)

如果沒有返回結果,則關閉資料庫編譯binary,具體檔案為$ORACLE_HOME/rdbms/lib/ins_rdbms.mk

make PL_ORALIBS=-laio -f ins_rdbms.mk async_on

 

justin_$ more aio-max-nr

1048576

justin_$ more aio-nr

98482

 

 

file-max/nr_open

核心支援的最大file handle數量/一個程式最多使用的file handle

justin_$ more file-max

6815744

justin_$ more nr_open

1048576

 

file-nr

3列分別為:已分配的檔案handle數量/已分配但沒有使用的/最大檔案handle

Linux 2.6起第2列一直為0 ,表示所有以分配的file  handle都在使用,但第1列應該經常變化

justin_$ more file-nr

786048  0       6815744

http://space.itpub.net/15480802/viewspace-734062 

 

 

inode-nr/ inode-state

Inode-max:最大inode數量,通常為file-max3-4倍,因為stdin/stdout/socket都需要inode,但2.6已經廢棄;

Inode-nr:列出inode-state的前兩個item,可以跳過不看

Inode-state:前3個列為nr_inodes/nr_free_inodes/preshrink,而前兩個分別表示已分配inode/空閒inode數;當nr_inodes > inode_maxpreshirnk = nr_inodes inode_max,此時系統需要清除排查inode列表;

justin_$ more inode-state

134123  41514   0       0       0       0       0

justin_$ more inode-nr

134123  41514

 

Overflowgid/ overflowuid

LinuxUID/GID32位,但有些檔案系統只支援16位的UID/GID,此時若進行寫操作會出錯;

UID/GID超過65535時會自動被轉換為一個固定值,即上述兩值

justin_$ more overflowgid

65534

justin_$ more overflowuid

65534

 

 

leases-enable/lease-break-time

linux也擁有檔案鎖,詳情參照

http://blog.csdn.net/yebanghua/article/details/7301904

 

justin_$ more lease-break-time

45

justin_$ more leases-enable

1

justin_$ more suid_dumpable

0

 

 

 

/proc/sys/fs還包含一些子目錄,諸如mqueue/quota/nfs/inotify

 

Mqueue目錄

POSIX訊息佇列用於程式間交換資料,與System V訊息佇列類似,以下3個引數用於其基本設定;

可透過ipcs q檢視當前系統的使用情況

justin_$ ipcs -q

 

------ Message Queues --------

key        msqid      owner      perms      used-bytes   messages   

msg_max

一個訊息佇列的最大訊息數,預設為10

justin_$ more msg_max

10

msgsize_max

單個訊息最大尺寸

justin_$ more msgsize_max

8192

queues_max

最大訊息佇列數

justin_$ more queues_max

256

 

 

 

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

相關文章