【OS】Linux下/dev/shm的作用及ORA-00845错误的处理

【OS】Linux下/dev/shm的作用

 

对/dev/shm认识

发表于 2011 年 09 月 25 日 由 惜分飞  

一、/dev/shm理论
/dev/shm/是linux下一个非常有用的目录,因为这个目录不在硬盘上,而是在内存里。因此在linux下,就不需要大费周折去建ramdisk,直接使用/dev/shm/就可达到很好的优化效果。 /dev /shm/需要注意的一个是容量问题,在linux下,它默认最大为内存的一半大小,使用df -h命令可以看到。但它并不会真正的占用这块内存,如果/dev/shm/下没有任何文件,它占用的内存实际上就是0字节;如果它最大为1G,里头放有 100M文件,那剩余的900M仍然可为其它应用程序所使用,但它所占用的100M内存,是绝不会被系统回收重新划分的,否则谁还敢往里头存文件呢?

默认系统就会加载/dev/shm ,它就是所谓的tmpfs,有人说跟ramdisk(虚拟磁盘),但不一样。象虚拟磁盘一样,tmpfs 可以使用您的 RAM,但它也可以使用您的交换分区来存储。而且传统的虚拟磁盘是个块设备,并需要一个 mkfs 之类的命令才能真正地使用它,tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。
  tmpfs有以下优势:
  1,动态文件系统的大小。
  2,tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。
  3,tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。所以有必要做一些脚本做诸如加载,绑定的操作。

二、修改/dev/shm大小
默认的最大一半内存大小在某些场合可能不够用,并且默认的inode数量很低一般都要调高些,这时可以用mount命令来管理它。
#mount -o size=1500M -o nr_inodes=1000000 -o noatime,nodiratime -o remount /dev/shm
在2G的机器上,将最大容量调到1.5G,并且inode数量调到1000000,这意味着大致可存入最多一百万个小文件。

如果需要永久修改/dev/shm的值,需要修改/etc/fstab
tmpfs /dev/shm tmpfs defaults,size=1.5G 0 0
#mount -o remount /dev/shm

三、/dev/shm应用
  首先在/dev/shm建个tmp文件夹,然后与实际/tmp绑定
  #mkdir /dev/shm/tmp
  #chmod 1777 /dev/shm/tmp
  #mount –bind /dev/shm/tmp /tmp(–bind )
  在使用mount –bind olderdir newerdir命令来挂载一个目录到另一个目录后,newerdir的权限和所有者等所有信息会发生变化。挂载后的目录继承了被挂载目录的所有属性,除了名称。Oracle 11g的amm内存管理模式就是使用/dev/shm,所以有时候修改MEMORY_TARGET或者MEMORY_MAX_TARGET会出现ORA-00845的错误




 

ORA-00845: MEMORY_TARGET not supported on this system

发表于 2011 年 11 月 05 日 由 惜分飞  

在Oracle 11g中如果采用AMM内存管理,那么当MEMORY_TARGET的值大于/dev/shm的时候,就会报ORA-00845: MEMORY_TARGET not supported on this system错误,解决办法增加/dev/shm大小,在redhat系列系统中,/dev/shm的默认值是系统总内存的一半

1、错误重现

SQL>SELECT *  FROM V$VERSION;  

   

BANNER  

——————————————————————————–  

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production  

PL/SQL Release 11.2.0.3.0 – Production  

CORE    11.2.0.3.0      Production  

TNS for Linux: Version 11.2.0.3.0 – Production  

NLSRTL Version 11.2.0.3.0 – Production  

   

SQL>show parameter memory;  

   

NAME                                 TYPE        VALUE  

———————————— ———– ——————————  

hi_shared_memory_address             integer     0  

memory_max_target                    big integer 500M  

memory_target                        big integer 500M  

shared_memory_address                integer     0  

SQL>alter system set memory_max_target=800m;  

alter system set memory_max_target=800m  

                 *  

ERROR at line 1:  

ORA-02095: specified initialization parameter cannot be modified  

   

   

SQL>alter system set memory_max_target=800m scope=spfile;  

   

System altered.  

   

SQL>alter system set memory_target=800m scope=spfile;   

   

System altered.  

   

SQL>shutdown immediate;  

Database closed.  

Database dismounted.  

ORACLE instance shut down.  

SQL>exit  

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production  

With the Partitioning, OLAP, Data Mining and Real Application Testing options  

[oracle@xifenfei admin]$ sqlplus / as sysdba  

   

SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 5 19:01:18 2011  

   

Copyright (c) 1982, 2011, Oracle.  All rights reserved.  

   

Connected to an idle instance.  

   

SQL>startup  

ORA-00845: MEMORY_TARGET not supported on this system  

SQL>!oerr ora 845  

00845, 00000, "MEMORY_TARGET not supported on this system"  

// *Cause: The MEMORY_TARGET parameter was not supported on this operating system or /dev/shm was not sized correctly on Linux.  

// *Action: Refer to documentation for a list of supported operating systems. Or, size /dev/shm to be at least the SGA_MAX_SIZE on each Oracle instance running on the system.  


2、修改/dev/shm大小


[root@xifenfei ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_xifenfei-lv_root

                       17G   13G  3.9G  77% /

tmpfs                 590M     0  590M   0% /dev/shm

/dev/sda1             485M   30M  430M   7% /boot

[root@xifenfei ~]# mount -o size=900M -o nr_inodes=1000000 -o noatime,nodiratime -o remount /dev/shm

[root@xifenfei ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_xifenfei-lv_root

                       17G   13G  3.9G  77% /

tmpfs                 900M     0  900M   0% /dev/shm

/dev/sda1             485M   30M  430M   7% /boot

[root@xifenfei ~]# vi /etc/fstab 

 

 

#

# /etc/fstab

# Created by anaconda on Sat Nov  5 02:49:30 2011

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_xifenfei-lv_root /                       ext4    defaults        1 1

UUID=7ace6c04-d232-43ac-9ef5-70ea92fe49bd /boot                   ext4    defaults        1 2

/dev/mapper/vg_xifenfei-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults,size=900M        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0    


3、启动数据库验证

[oracle@xifenfei admin]$ sqlplus / as sysdba    

     

SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 5 19:03:51 2011    

     

Copyright (c) 1982, 2011, Oracle.  All rights reserved.    

     

     

Connected to:    

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production    

With the Partitioning, OLAP, Data Mining and Real Application Testing options    

     

sys@XFF>show parameter memory;    

     

NAME                                 TYPE        VALUE    

———————————— ———– ——————————    

hi_shared_memory_address             integer     0    

memory_max_target                    big integer 800M    

memory_target                        big integer 800M    

shared_memory_address                integer     0      


4、官方解释
Starting with Oracle Database 11g, the Automatic Memory Management feature requires more shared memory (/dev/shm)and file descriptors. The size of the shared memory should be at least the greater of MEMORY_MAX_TARGET and MEMORY_TARGET for each Oracle instance on the computer. If MEMORY_MAX_TARGET or MEMORY_TARGET is set to a non zero value, and an incorrect size is assigned to the shared memory, it will result in an ORA-00845 error at startup.

5、解决问题建议
5.1. If you are installing Oracle 11g on a Linux system, note that Memory Size (SGA and PGA), which sets the initialization parameter MEMORY_TARGET or MEMORY_MAX_TARGET, cannot be greater than the shared memory filesystem (/dev/shm) on your operating system. To resolve the current error, increase the /dev/shm file size.

5.2. If configuring AMM is not possible due to lack of space on /dev/shm mount point, you can configure ASMM instead of AMM, i.e. set SGA_TARGET, SGA_MAX_SIZE and PGA_AGGREGATE_TARGET instead of MEMORY_TARGET.

在redhat6中,修改了fstab中修改后,不能生效,需要重新挂载
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=900M 0 0

vi /etc/rc.local
mount -o remount /dev/shm


 




      linux下/dev/shm的大小引发ORA-00845: MEMORY_TARGET not supported on this system      
 
 

原文地址:linux下/dev/shm的大小引发ORA-00845: MEMORY_TARGET not supported on this system 作者:eric0435


Linux操作系统,oracle 11.2.0.4 启动实例时出现如下错误:

SQL> startup nomount pfile=/u03/app/oracle/11.2.0/db/dbs/initcssb.ora
ORA-00845: MEMORY_TARGET not supported on this system

查看错误帮助信息

[oracle11@oracle11g dbs]$ oerr ora 845
00845, 00000, "MEMORY_TARGET not supported on this system"
// *Cause: The MEMORY_TARGET parameter was not supported on this operating system or /dev/shm was not sized correctly on Linux.
// *Action: Refer to documentation for a list of supported operating systems. Or, size /dev/shm to be at least the SGA_MAX_SIZE on each Oracle instance running on the system.

错误原因是这个操作系统不支持MEMORY_TARGET参数或/dev/shm在Linux上的大小不正确造成的,这是该操作系统上的第二个实例,第一个实例设置了MEMORY_TARGET参数,所以并不是不支持这个参数,原因就只有/dev/shm大小不正确了,解决方法是要将/dev/shm的最小值设置为操作系统上运行实例SGA_MAX_SIZE所设置的大小。/dev/shm/是linux下一个目录,/dev/shm目录不在磁盘上,而是在内存里,因此使用linux /dev/shm/的效率非常高,直接写进内存。
tmpfs有以下特点:
1.tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。
2.动态文件系统的大小。
3.tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。
4.tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。所以有必要做一些脚本做诸如加载、绑定的操作。

linux下/dev/shm的容量默认最大为内存的一半大小,使用df -h命令可以看到。但它并不会真正的占用这块内存,如果/dev/shm/下没有任何文件,它占用的内存实际上就是0字节;如果它最大为1G,里头放有100M文件,那剩余的900M仍然可为其它应用程序所使用,但它所占用的100M内存,是绝不会被系统回收重新划分的。

linux /dev/shm容量(大小)是可以调整,在有些情况下(如oracle数据库)默认的最大一半内存不够用,并且默认的inode数量很低一般都要调高些,这时可以用mount命令来管理它。
mount -o size=1500M -o nr_inodes=1000000 -o noatime,nodiratime -o remount /dev/shm
在2G的机器上,将最大容量调到1.5G,并且inode数量调到1000000,这意味着大致可存入最多一百万个小文件通过/etc/fstab文件来修改/dev/shm的容量(增加size选项即可),修改后,重新挂载即可。

这里该实例的SGA_MAX_SIZE为1G,下面的命令查看/dev/shm的大小。

[root@oracle11g ~]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              23G   20G  1.6G  93% /
/dev/sdb1             9.9G  5.8G  3.6G  62% /u02
tmpfs                 2G    1.3M  0.7G  65% /dev/shm

从上面结果可以看到/dev/shm可用大小只有0.7G,执行下面的命令来进行修改。

[root@oracle11g ~]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
/dev/sdb1               /u02                    ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults,size=4G        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0

"/etc/fstab" 7L, 540C written

卸载/dev/shm,但/dev/shm正被访问

[root@oracle11g ~]#  umount /dev/shm
umount: /dev/shm: device is busy
umount: /dev/shm: device is busy

用fuser处理,fuser命令,-k:kill processes accessing the named file(杀死所有正在访问指定文件的进程),-m 表示指定文件所在的文件系统或者块设备(处于 mount 状态)。所有访问该文件系统的进程都被列出。

[root@oracle11g ~]# fuser -km /dev/shm
/dev/shm:             3152m  3154m  3156m  3160m  3162m  3164m  3166m  3168m  3170m  3172m  3174m  3176m  3178m  3180m  3182m  3184m  3186m  3193m  3195m  3197m  3199m  3201m  3236m  3248m  3250m  3256m  3292m  4366m
[root@oracle11g ~]#  umount /dev/shm
[root@oracle11g ~]# mount /dev/shm
[root@oracle11g ~]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              23G   20G  1.6G  93% /
/dev/sdb1             9.9G  5.8G  3.6G  62% /u02
tmpfs                 4.0G     0  4.0G   0% /dev/shm

再重新启动实例
SQL> startup nomount pfile=/u03/app/oracle/11.2.0/db/dbs/initcssb.ora
ORACLE instance started.

Total System Global Area 1334786560 bytes
Fixed Size 1364480 bytes
Variable Size 171970048 bytes
Database Buffers 1155189248 bytes
Redo Buffers 6262784 bytes

小结:Oracle 11g的AMM内存管理模式就是使用/dev/shm,所以有时候修改MEMORY_TARGET或者MEMORY_MAX_TARGET会出现ORA-00845的错误,在安装配置实例内存时为了避免出现这个故障可以对Linux系统中的/dev/shm进行调整,让其可用大小至少等于实例的sga_max_size。



  Oracle 11g引入了MEMORY_TARGET参数,用于控制oracle对于系统内存的使用,首次将SGA和PGA整合在一起实现自动管理,一旦设置了Memory_target 参数,oracle就会根据需要自动调整SGA和PGA以合理分配及使用内存。如果Memory_target设置不当,就容易引发ORA-00845错误。原因是Memory_target和/dev/shm (即tmpfs)有紧密联系。下面就来研究下/dev/shm究竟是什么,他的作用是什么,如何修改以及他的应用场景

 

一、/dev/shm是什么

       /dev/shm是linux非常有用的一个目录,它就是所谓的tmpfs,也可以称之为临时文件系统(不是块设备),类似oracle中的临时表空间一样,用于加速和优化系统。该目录并没有放在磁盘上,而上在内存当中。因此在linux下,不用大费周折的去建ramdisk,直接使用/dev/shm就可以达到很好的效果。

       Tmpfs和ramdisk(虚拟磁盘)。Tmpfs可以使用RAM,也可以使用交换分区来进行存储。传统的ramdisk(虚拟磁盘)是个块设备,并且需要mkfs之类的命令之后才可以真正的使用它。Tmpfs是一个文件系统,不是块设备,系统默认启动就会加载/dev/shm,只要安装它就可以使用了。

       Tmpfs优势。

1.    动态文件系统的大小

2.    读写速度快。典型的tmpfs文件系统会完全驻留在RAM中,读写几乎是瞬间完成。

3.    Tmpfs中的数据在重新启动之后不会保留,因为虚拟内存本质上是易失的,所以有必要做些脚本做诸如加载、绑定的操作。

 

注意

在oracle数据库启动后,在/dev/shm目录下会产生大量ORA文件,一定不要试图去删除这些文件,删除之后,oracle数据库会宕掉。

 

 

二、/dev/shm如何修改大小

 

       关于/dev/shm容量的问题,在linux下,默认/dev/shm为实际物理内存的1/2,使用df –h命令查看。实际上它不会真正的占用这块内存。如果/dev/shm下没有任何文件,它实际占用的内存就是0字节;如果它最大为1G,里面放有100M的文件,那么剩余的900M任然可以被其他应用程序所使用,但是已经占用的这100M内存空间是不会被系统回收重新划分的。

       临时调整tmpfs大小,重启后失效

默认的最大一半内存在某些场合可能不够用,并且默认的额inode数量很低,一般都要调高些,可以用下面的命令来实现

#mount–o size=1500m –o nr_inodes=1000000 –o noatime,nodiratime –o remount /dev/shm

在2G的机器上,/dev/shm最大尺寸调整到1.5G,并且inode数量调整到1000000,这意味着大致可存入100万个小文件

       永久修改tmpfs大小,修改/etc/fstab文件

tmpfs /dev/shm tmpfsdefaults,size=1500M 0 0

修改之后remount

#mount –o remount  /dev/shm

注意:

这里一定要注意,修改的size一定要是整数,否则在remount时候会遇到如下问题

#mount –o remount /dev/shm

mount: wrong fs type,bad option, bad superblockon tmpfs,

 missingcodepage or other error

 In somecases useful info is found in syslog – try

 dmesg |tail  or so

# dmesg | tail

Bluetooth: L2CAP socket layerinitialized

Bluetooth: RFCOMM socketlayer initialized

Bluetooth: RFCOMM TTY layerinitialized

Bluetooth: RFCOMM ver 1.8

Bluetooth: HIDP (HumanInterface Emulation) ver 1.1

mtrr: your processor doesn'tsupport write-combining

mtrr: your processor doesn'tsupport write-combining

tmpfs: Bad value '1.5G' formount option 'size'

tmpfs: Bad value '1.5G' for mount option 'size'

tmpfs: Bad value '0.5G' for mount option 'size'

三、/dev/shm应用

首先在/dev/shm建个tmp文件夹,然后与实际/tmp绑定,把/dev/shm绑定到/tmp目录上
#mkdir /dev/shm/tmp
  #chmod 777 /dev/shm/tmp
  #mount –bind /dev/shm/tmp/tmp(–bind )
  在使用mount –bind olderdirnewerdir命令来挂载一个目录到另一个目录后,newerdir的权限和所有者等所有信息会发生变化。挂载后的目录继承了被挂载目录的所有属性,除了名称。Oracle 11g的amm内存管理模式就是使用/dev/shm,所以有时候修改MEMORY_TARGET或者MEMORY_MAX_TARGET会出现ORA-00845的错误

 

四、tmpfs文档

 

Tmpfsis a file system which keeps all files in virtual memory.

Everythingin tmpfs is temporary in the sense that no files will be
created on your hard drive. If you unmount a tmpfs instance,
everything stored therein is lost.

tmpfsputs everything into the kernel internal caches and grows and
shrinks to accommodate the files it contains and is able to swap
unneeded pages out to swap space. It has maximum size limits which can
be adjusted on the fly via ‘mount -o remount …’

Ifyou compare it to ramfs (which was the template to create tmpfs)
you gain swapping and limit checking. Another similar thing is the RAM
disk (/dev/ram*), which simulates a fixed size hard disk in physical
RAM, where you have to create an ordinary filesystem on top. Ramdisks
cannot swap and you do not have the possibility to resize them.

Sincetmpfs lives completely in the page cache and on swap, all tmpfs
pages currently in memory will show up as cached. It will not show up
as shared or something like that. Further on you can check the actual
RAM+swap use of a tmpfs instance with df(1) and du(1).

tmpfshas the following uses:

1)There is always a kernel internal mount which you will not see at
all. This is used for shared anonymous mappings and SYSV shared
memory.

Thismount does not depend on CONFIG_TMPFS. If CONFIG_TMPFS is not
set, the user visible part of tmpfs is not build. But the internal
mechanisms are always present.

2)glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
POSIX shared memory (shm_open, shm_unlink). Adding the following
line to /etc/fstab should take care of this:

tmpfs/dev/shm tmpfs defaults 0 0

Rememberto create the directory that you intend to mount tmpfs on
if necessary (/dev/shm is automagically created if you use devfs).

Thismount is _not_ needed for SYSV shared memory. The internal
mount is used for that. (In the 2.3 kernel versions it was
necessary to mount the predecessor of tmpfs (shm fs) to use SYSV
shared memory)

3)Some people (including me) find it very convenient to mount it
e.g. on /tmp and /var/tmp and have a big swap partition. But be
aware: loop mounts of tmpfs files do not work due to the internal
design. So mkinitrd shipped by most distributions will fail with a
tmpfs /tmp.

4)And probably a lot more I do not know about

tmpfshas a couple of mount options:

size:The limit of allocated bytes for this tmpfs instance. The
default is half of your physical RAM without swap. If you
oversize your tmpfs instances the machine will deadlock
since the OOM handler will not be able to free that memory.
nr_blocks: The same as size, but in blocks of PAGECACHE_SIZE.
nr_inodes: The maximum number of inodes for this instance. The default
is half of the number of your physical RAM pages.

Theseparameters accept a suffix k, m or g for kilo, mega and giga and
can be changed on remount.

Tospecify the initial root directory you can use the following mount
options:

mode:The permissions as an octal number
uid: The user id
gid: The group id

Theseoptions do not have any effect on remount. You can change these
parameters with chmod(1), chown(1) and chgrp(1) on a mounted filesystem.

So‘mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs’
will give you tmpfs instance on /mytmpfs which can allocate 10GB
RAM/SWAP in 10240 inodes and it is only accessible by root.

TODOs:

1)give the size option a percent semantic: If you give a mount option
size=50% the tmpfs instance should be able to grow to 50 percent of
RAM + swap. So the instance should adapt automatically if you add
or remove swap space.
2) loop mounts: This is difficult since loop.c relies on the readpage
operation. This operation gets a page from the caller to be filled
with the content of the file at that position. But tmpfs always has
the page and thus cannot copy the content to the given page. So it
cannot provide this operation. The VM had to be changed seriously
to achieve this.
3) Show the number of tmpfs RAM pages. (As shared?)

Author:
Christoph Rohland , 1.12.01

 

 五、Doc ID 1399209.1

Starting with Oracle Database 11g, the Automatic MemoryManagement feature requires more shared memory (/dev/shm) and file descriptors.The size of the shared memory must be at least the greater of theMEMORY_MAX_TARGET and MEMORY_TARGET parameters for each Oracle instance on thecomputer. If the MEMORY_MAX_TARGET parameter or the MEMORY_TARGET parameter isset to a nonzero value, and an incorrect size is assigned to the shared memory,it results in an ORA-00845 error at startup. 
On Linux systems, if the operating system /dev/shm mount size is too small forthe Oracle system global area (SGA) and program global area (PGA), then youencounter the following error:

The cause of this error is an insufficient /dev/shm allocation.The total memory size of the SGA and PGA, which sets the initializationparameter MEMORY_TARGET or MEMORY_MAX_TARGET, cannot be greater than the sharedmemory file system (/dev/shm) on your operating system.

 

整理自网络

 



使用redhat系列的操作系统,可以发现系统默认挂载了/dev/shm,挂载类型为tmpfs。

在glibc2.2以上的版本,使用/dev/shm 作为POSIX 共享内存 (shm_open, shm_unlink),在fstab上可以看到

tmpfs /dev/shm tmpfs defaults 0 0

这里要说下tmpfs。

tmpfs从名字看就知道是临时文件系统,所以写入到tmpfs类型的分区下的文件都不会写入硬盘,只是保存在硬盘里,tmpfs在挂载时如果没有指定size默认使用物理内存的一半作为它的值。相对于ramfs,tmpfs有它一系列的优势,首先它能被用于交换,更重要的是挂载一个tmpfs类型的分区并不实际占用物理内存(当然往里写了就开始占内存了,即写1M的文件进去,就占了1M)。而ramfs的话在初始化的时候就限制了,必须分配掉相应的内存作为物理磁盘,事实上就算你还没用内存就已经少掉了。

利用tmpfs,同样的,我可以手动创建个目录并挂载

mount -t proc none /mnt/1

这样,/mnt/1 也是tmpfs类型。使用df -h可以看到多了个分区,并且大小也是内存的一半。之后就随便怎么用啦~

最后当umount掉分区后,所有该分区的文件就自动消失了,内存被释放。

ORACLE 数据库从11g 版本开始,引入了一个自动内存管理(Automatic Memory Management)特性,该特性需要更多的共享内存(/dev/shm),因此如果决定应用该特性的话, 必须要确保共享内存大于ORACLE 中初始化参数MEMORY_MAX_TARGET 和MEMORY_TARGET(特别提示,这两个参数即自动内存管理特性对应的初始化参数)的值。
如果在初始化参数中设置了MEMORY_MAX_TARGET 和MEMORY_TARGET 两参数为非0 值,并且不符合系统共享内存,则ORACLE 数据库启动时,就会触发ORA-00845:MEMORY_TARGET not supported on this system 错误。

ORACLE官方文档中的原话为:
Automatic Memory Management
Starting with Oracle Database 11g, the Automatic Memory Management feature requires more shared memory (/dev/shm)and file descriptors. The size of the shared memory should be at least the greater of MEMORY_MAX_TARGET and MEMORY_TARGET
for each Oracle instance on the computer. If MEMORY_MAX_TARGET or MEMORY_TARGET is set to a non zero value, and an incorrect size is assigned to the shared memory, it will result in an ORA-00845 error at startup. On Linux systems, if the operating system /dev/shm mount size is too small for the Oracle system global area (SGA) and program global area (PGA), even then it will result in an ORA-00845 error.
The number of file descriptors for each Oracle instance should be at least 512*PROCESSES. Also, the limit of descriptors for each process should be at least 512.
If file descriptors are not sized correctly, you will notice ORA-27123 from various Oracle processes and potentially Linux Error EMFILE (Too many open files) errors in non-Oracle processes.
To determine the amount of shared memory available, enter the following command:

# df -h /dev/shm/




 

Linux umount 报 device is busy 的处理方法



 

       今天在IDC 辐射了半天,又弄了套DG。 在Linux 挂盘这块也小学了两招。

 

一.  umout 移动硬盘

       开始用sftp 将安装文件copy到服务器的时候,速度太慢了,500k/s。几个G的东西,copy 这些就要半个多小时,扛不住,拿移动硬盘来copy了。结果移动硬盘的格式不对。 是NTFS 格式,Linux 识别不了。 只能格式化成FAT32的。 而GG 的win7 系统又不具备格式化成FAT32的功能。 有点小变态。让同事在XP 下帮我格式化了。

 

       安装文件copy到服务器后,同事直接将移动硬盘从服务器上拔下来了。 导致的结果是,用df 命令查看,挂载的移动硬盘还存在。

 

[root@qs-wg-db1 ~]# df -lh

Filesystem            Size  Used Avail Use% Mounted on

/dev/sdb3             125G  3.3G  115G   3% /

/dev/sdb1              99M   12M   82M  13% /boot

tmpfs                 3.9G     0  3.9G   0% /dev/shm

/dev/sda1             275G   72G  189G  28% /u01

/dev/sdc1              10G  2.0G  8.1G  20% /datatmp

 

就是这个/dev/sdc1。

 

这时使用umount 命令,会提示设备忙,无法挂载。

 

处理方法:

[root@qs-wg-db1 ~]# fuser -km /datatmp

[root@qs-wg-db1 ~]# df -lh

Filesystem            Size  Used Avail Use% Mounted on

/dev/sdb3             125G  3.3G  115G   3% /

/dev/sdb1              99M   12M   82M  13% /boot

tmpfs                 3.9G     0  3.9G   0% /dev/shm

/dev/sda1             275G   72G  189G  28% /u01

/dev/sdc1              10G  2.0G  8.1G  20% /datatmp

[root@qs-wg-db1 ~]# umount /datatmp

[root@qs-wg-db1 ~]# df -lh

Filesystem            Size  Used Avail Use% Mounted on

/dev/sdb3             125G  3.3G  115G   3% /

/dev/sdb1              99M   12M   82M  13% /boot

tmpfs                 3.9G     0  3.9G   0% /dev/shm

/dev/sda1             275G   72G  189G  28% /u01

 

成功umount了。

 

二.  umount 光驱

       安装DB 之前,检查了一下相关包,少了3个。 从系统安装盘上找了包,安装了一下。 当时是直接将/dev/cdrom mount 到了/mnt目录。 也是图个方便。 结果收工时去拿盘,光驱弹不出来。 同事让我把cdrom umout掉。 同样的提示,设备忙。

 

处理方法:

[root@qs-wg-db1 ~]#fuser –km /dev/cdrom

[root@qs-wg-db1 ~]#eject  -- 弹出光驱

 

 

在网上搜了一下,正确挂载CD-ROM的方法应该如下:

 

# mkdir cdrom
# mount /dev/cdrom /mnt/cdrom
或者 

# mount /dev/cdrom /media/cdrom

 

直接挂载在/mnt,/media等系统目录下,在umount时会出现出错信息“umount: /mnt/cdrom: device is busy”的情况。

 

如果一个文件系统处于“busy”状态的时候,不能卸载该文件系统。如下情况将导致文件系统处于“busy”状态:

       1) 文件系统上面有打开的文件

       2) 某个进程的工作目录在此文件系统上

       3) 文件系统上面的缓存文件正在被使用

 

三.  fuser 命令

       前面2个umout 都使用了这个fuser 命令。 man了一下这个命令。 内容如下:

 

[root@qs-wg-db1 ~]# man fuser

FUSER(1)       User Commands                        FUSER(1)

 

NAME

       fuser - identify processes using files or sockets

 

SYNOPSIS

       fuser [-a|-s|-c] [-4|-6] [-n  space ] [-k [-i] [-signal ] ] [-muvf] name

       fuser -l

       fuser -V

 

DESCRIPTION

       fuser displays the PIDs of processes using the specified files or file systems.  In the default display mode, each file name is followed by a letter denoting the  type

       of access:

              c      current directory.

              e      executable being run.

              f      open file. f is omitted in default display mode.

              F      open file for writing. F is omitted in default display mode.

              r      root directory.

              m      mmap'ed file or shared library.

 

       fuser  returns a non-zero return code if none of the specified files is accessed or in case of a fatal error. If at least one access  has  been  found,  fuser  returns zero.

       In  order  to  look  up processes using TCP and UDP sockets, the corresponding name space has to be selected with the -n option. By default fuser  will  look  in  both IPv6  and IPv4 sockets. To change the default, behavior, use the -4 and -6 options. The socket(s) can be specified by  the  local  and  remote  port,  and  the  remote address.  All  fields  are optional, but commas in front of missing fields must be present:

       [lcl_port][,[rmt_host][,[rmt_port]]]

       Either symbolic or numeric values can be used for IP addresses and port numbers.

      

fuser outputs only the PIDs to stdout, everything else is sent to stderr.

 

OPTIONS

       -a     Show all files specified on the command line. By default,  only  files  that are accessed by at least one process are shown.

       -c     Same as -m option, used for POSIX compatibility.

       -f     Silently ignored, used for POSIX compatibility.

       -k     Kill  processes  accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never kills itself, but may  kill  other  fuser  processes.  The  effective user ID of the process executing fuser is set to its real user ID before attempting to kill.

       -i     Ask the user for confirmation before  killing  a  process.  This  option  is silently ignored if -k is not present too.

       -l     List all known signal names.

       -m    name  specifies  a  file  on a mounted file system or a block device that is mounted. All processes accessing files on that file system are listed.  If adirectory  file  is  specified, it is automatically changed to name/. to use any file system that might be mounted on that directory.

 

       -n space Select a different name  space.  The  name  spaces  file  (file  names,  the default),  udp  (local UDP ports), and tcp (local TCP ports) are supported. For ports, either the port number or the symbolic name can be specified.  If there  is no ambiguity, the shortcut notation name/Ispace (e.g. 80/tcp ) can be used.

       -s     Silent operation. -u and -v are ignored in this mode.  -a must not  be  used with -s.

       -signal Use  the specified signal instead of SIGKILL when killing processes. Signals can be specified either by name (e.g. -HUP) or by  number  (e.g.  -1).  This option is silently ignored if the -k option is not used.

       -u     Append the user name of the process owner to each PID.

       -v     Verbose  mode.  Processes are shown in a ps-like style. The fields PID, USER and COMMAND are similar to ps. ACCESS shows how  the  process  accesses  the file.  If  the access is by the kernel (e.g. in the case of a mount point, awap file, etc.), kernel is shown instead of the PID.

       -V     Display version information.

       -4     Search only for IPv4 sockets. This option must  not  be  used  with  the  -6 option and only has an effect with the tcp and udp namespaces.

       -6     Search  only  for  IPv6  sockets.  This  option must not be used with the -4 option and only has an effect with the tcp and udp namespaces.

       -      Reset all options and set the signal back to SIGKILL.

FILES

       /proc     location of the proc file system

 

fuser 命令显示访问某个文件的进程的PID. 其中-k 和 -m 参数上面红色部分有说明。-k 是kill 访问这个文件的进程。 没有进程访问,就可以成功umount了.


上一篇:linux共享内存2---Posix共享内存


下一篇:an upstream response is buffered to a temporary file