oracle对/dev/shm的使用

查看共享内存打开的文件数

  1. [root@db2 ~]# lsof -n | grep /dev/shm | wc -l
  2. 34693

共享内存中总共文件数

[root@db2 ~]# ls -l /dev/shm | wc -l
495

Why is Oracle keeping hundreds of thousands Open File descriptors in /dev/shm while there are just hundreds of files ?

解释:

查看每个进程打开的文件数:

  1. [root@db2 ~]# ps -ef | grep ora_smon | grep -v grep
  2. oracle 13984 1 0 Dec07 ? 00:17:30 ora_smon_db2
  3. [root@db2 ~]# lsof | grep 13984 | grep -v grep | wc -l
  4. 456

每个进程打开的文件数大约等于/dev/shm中的文件数

查看数据库的进程数:

  1. [root@db2 ~]# ps -ef | grep -v grep | grep -i ora_ | wc -l

  2. 76

计算:进程数*每个进程打开的文件数 约= 共享内存打开的文件数(76*456 = 34656) 约等于lsof -n | grep /dev/shm 得出的数


下列文章来自(MOS:1321306.1

1) Let's use a test database (11.1.0.7) to demonstrate how Automatic Memory Management uses file descriptors and why there are so many Open File descriptors. 

A) Before starting the 11.1.0.7 database, /dev/shm is empty and there are no open files 

$ ls -l /dev/shm
total 0
$ lsof -n | grep /dev/shm


B)  Let's start the database, then check /dev/shm

UNIX> sqlplus " / as sysdba"
       SQL*Plus: Release 11.1.0.7.0 - Production on Fri May 6 14:57:28 2011
       Copyright (c) 1982, 2008, Oracle. All rights reserved.
       Connected to an idle instance.

 SQL> startup
       ORACLE instance started.
       Total System Global Area 845348864 bytes
       Fixed Size 1316656 bytes
       Variable Size 578816208 bytes
       Database Buffers 260046848 bytes
       Redo Buffers 5169152 bytes
       Database mounted.
       Database opened.

 

SQL> show parameter memory_target
NAME           TYPE        VALUE
-------------- ----------- ------
memory_target  big integer 808M



SQL> show parameter memory_max_target
  NAME              TYPE          VALUE
 ----------------- ------------- ------ 
 memory_max_target  big integer  808M



C) let's check /dev/shm again

UNIX> ls -l /dev/shm/* | wc -l
           203
UNIX> lsof -n | grep /dev/shm | wc -l
            4872



Number of files in /dev/shm

There are 203 files  ( 4 MB size, which is the granule size)   (内存粒度的说明见oracle内存粒度的说明
This is approximately MEMORY_TARGET/4MB 
Since MEMORY_TARGET < 1 GB,  203 x 4 MB files are created

For a larger MEMORY_TARGET,  the number of files in /dev/shm = MEMORY_TARGET/granule size

See Note 947152.1 How to determine granule size.

Number of open files descriptors

There are 4872 open files handles why ?

After starting the 11.1.0.7 database, 24 background processes were created
UNIX> ps -ef | grep -i <database name> | wc -l
24


Each background process open 203 files x 24 = 4872
UNIX> lsof -n | grep /dev/shm | wc -l
4872



总结:


ls -l /dev/shm | wc -l              open files = MEMORY_TARGET/granule size

lsof -n | grep /dev/shm | wc -l   open file descriptos = open files*进程数






















posted @ 2016-12-31 23:37  hao_xiaoyu  阅读(1233)  评论(0编辑  收藏  举报