ORA-00845: MEMORY_TARGET not supported on this system

最近在玩12c,在Oracle Linux 6.3上搭一个单实例带grid,在DBCA建库的时候出现:
ORA-00845: MEMORY_TARGET not supported on this system

或者在启动数据库的时候:

SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system

接着建库中止,仔细研究后发现,造成这个问题是由于设置SGA的大小超过系统的/dev/shm的大小:

[root@12c ~]# df -k /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                  2027740    645152   1382588  32% /dev/shm

查看alert_orcl.log日志,找到如下报错:

WARNING: You are trying to use the MEMORY_TARGET feature. This feature requires the /dev/shm file system to be mounted for at least 1644167168 bytes. /dev/shm is either not mounted or is mounted with available space less than this size. Please fix this so that MEMORY_TARGET can work as expected. Current available is 1415770112 and used is 660635648 bytes. Ensure that the mount point is /dev/shm for this directory.
Wed Jul 31 21:04:42 2013
memory_target needs larger /dev/shm
看到日志中:
当前大小:1415770112 bytes  =1350.1834 MB

期望大小: at least 1644167168 bytes  = 1568 MB

一般来说,shm默认大小是系统内存的1/2大小。即系统内存是4G,则tmpfs就是2G。你可能会说既然期望是1568MB,2G也足够了,这里不能忘记还有ASM实例又会占用一些内存,剩下的就小于1568m了。

方法1:调低MEMORY_TARGET内存

alter system set MEMORY_MAX_TARGET=1G scope=spfile;

当然如果已经无法启动库,也没法操作上述命令。而且对于真实应用调低MEMORY_TARGET内存也不是很实用。具体方法就不示范,以方法2为主。

方法2:修改shm容量

[root@12c ~]# umount /dev/shm
umount: /dev/shm: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@12c ~]# ls  /dev/shm
ora_+ASM_5308430_0    ora_+ASM_5341199_18   ora_+ASM_5341199_262
ora_+ASM_5308430_1    ora_+ASM_5341199_180  ora_+ASM_5341199_263
ora_+ASM_5341199_0    ora_+ASM_5341199_181  ora_+ASM_5341199_264
ora_+ASM_5341199_1    ora_+ASM_5341199_182  ora_+ASM_5341199_265
ora_+ASM_5341199_10   ora_+ASM_5341199_183  ora_+ASM_5341199_266
.............................

发现shm也在被Grid进程正在使用,为了umount该装载点,必须先得shutdown ASM instance

如果有数据库则先关闭数据库
su - grid
sqlplus / as sysasm
shutdown immediate

再次查看

[root@12c ~]# ls  /dev/shm
pulse-shm-2298131991  pulse-shm-2650250879
pulse-shm-2472803980  pulse-shm-737986347
#还有进程占用
[root@12c ~]# fuser -m -v /dev/shm      #详细查看那些进程正在使用
Cannot stat file /proc/2350/fd/79: No such file or directory
Cannot stat file /proc/2350/fd/80: No such file or directory
                     USER        PID ACCESS COMMAND
/dev/shm:            oracle     2753 ....m gnome-settings-
                     oracle     2775 ....m pulseaudio
                     oracle     2815 ....m gnome-volume-co
                     oracle     2836 ....m gpk-update-icon

fuser -m -k /dev/shm   #自动杀正在使用的进程
fuser -m -i -k /dev/shm  #杀进程前会询问
vi /etc/fstab 
tmpfs                   /dev/shm                tmpfs   defaults,size=4g        0 0

这时候不妨把值给的更大一点,因为还有ASM实例会需要占用一部分。

或者也可以直接

vi /etc/fstab 

mount -o remount /dev/shm

但是请注意,以上方法在OL6.3中,哪怕是修改/etc/fstab,重启机器后也还是会变成默认。实测在5.8的版本中修改/etc/fstab应该是直接生效的。

所以需要在开机后马上执行下:mount -o remount /dev/shm

或者一劳永逸的方法

使用暴力方法,在开机的过程中remount。(强烈推荐

增加红色部分:

[root@12c ~]# vi /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
mount -o remount /dev/shm

———————————————

也可以通过/etc/rc.d/rc.sysinit使fstab中tmpfs的修改生效

注释如下语句

#mount -f /dev/shm >/dev/null2>&1

在rc.syinit中找到如下内容:

if [ "$READONLY" != "yes" ] ; then
        action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
else
        action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
fi

在如下部分里添加tmpfs这个类型:

if [ "$READONLY" != "yes" ] ; then
        action $"Mounting local filesystems: " mount -a -t tmpfs,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
else
        action $"Mounting local filesystems: " mount -a -n -t tmpfs,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
fi

 方法3:

vim /etc/rc.d/rc.sysinit      
change the line:
mount -f /dev/shm>/dev/null 2>&1
to
mount /dev/shm>/dev/null 2>&1

 

留下评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据