“ORA-00845: MEMORY_TARGET not supported on this system”不完全解決之道

shsnchyw發表於2014-12-12
最近在玩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

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

相關文章