天天看点

ORA-00845 MEMORY_TARGET not supported on this system 解决Linux上11g的ORA-00845错误

ORA- 00845: MEMORY_TARGET not supported on this system

我建立虚拟机的时候 选择的是8G的内存,但是检查的时候报错,我只有4G提示 Swap分区不够, 其实是可以使用DD命令解决的。  GG 同步不起。

解决Linux上11g的ORA-00845错误

下午想把一个11.2.0.2实例的memory_target AMM内存初始化参数修改到2000M,改好后重启发现实例起不来了,出现了ORA-00845错误:

[[email protected] ~]$ 
[[email protected] ~]$ sqlplus  / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 3 19:43:50 2011

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

Connected to an idle instance.

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

======================= ALERT.LOG======================

Starting ORACLE instance (normal)
WARNING: You are trying to use the MEMORY_TARGET feature. 
This feature requires the /dev/shm file system to be mounted for at least 2097152000 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 1871466496 and used is 200790016 bytes. 
Ensure that the mount point is /dev/shm for this directory.
memory_target needs larger /dev/shm      

看起来是因为采用了Automatic Memory Management的特性,所以Oracle采用了一种基于POSIX的共享内存使用风格,在AMM中Oracle不像之前版本那样利用”一整块”内存作为SGA,而是使用一块块小的”chunk”,以满足SGA与PGA之前交换内存的目的

针对上述ORA-00845错误,我们需要修改映射内存文件夹/dev/shm的装载参数,针对正在运行的Linux操作系统,可以remount这个tmpfs装载点,如:

[[email protected] ~]# umount /dev/shm
umount: /dev/shm: device is busy
umount: /dev/shm: device is busy

[[email protected] ~]# ls /dev/shm
JOXSHM_EXT_0_PROD1_8323079   JOXSHM_EXT_25_PROD1_8323079  ora_+ASM1_7569414_11  
JOXSHM_EXT_10_PROD1_8323079  JOXSHM_EXT_26_PROD1_8323079  ora_+ASM1_7569414_12  
............

/* 可以看到如果ASM实例也使用AMM的话同样会在/dev/shm目录下产生内存映像 
    为了umount该装载点,我们不得不首先shutdown ASM instance ! */

[[email protected] ~]# su - grid
[[email protected] ~]$ sqlplus  / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 3 20:05:24 2011

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> shutdown immediate;
ORA-01031: insufficient privileges
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
[[email protected] ~]$ sqlplus  / as sysasm

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 3 20:05:32 2011

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> shutdown immediate;
ORA-15097: cannot SHUTDOWN ASM instance with connected client (process 1576)
SQL> shutdown abort;
ASM instance shutdown
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

[[email protected] ~]# umount /dev/shm

[[email protected] ~]# mount -t tmpfs shmfs -o size=4000m /dev/shm

/* 这里的size指定了shm目录的装载大小,4000m可能对你的系统仍然不够,
    那么你有理由设一个更大的值  */


[[email protected] ~]# mount|grep shmfs
shmfs on /dev/shm type tmpfs (rw,size=4000m)

Startup ASM...........

[[email protected] ~]# su - oracle
[[email protected] ~]$ sqlplus  / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue May 3 20:09:40 2011

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 2087780352 bytes
Fixed Size                  2228072 bytes
Variable Size            1476395160 bytes
Database Buffers          603979776 bytes
Redo Buffers                5177344 bytes

/* 实例启动成功! */      

上述umount/mount的方式只在操作系统的此次生命周期中生效,如果重启的话shmfs目录仍会以默认方式装载;如果需要永久生效的话,我们需要修改系统参数文件/etc/fstab中的shm条目:

/* 修改前的shm装载参数 */

[[email protected] ~]# grep shm /etc/fstab 
tmpfs                   /dev/shm                tmpfs   defaults        0 0

/* 修改后的shm装载参数 */

[[email protected] ~]# grep shm /etc/fstab 
tmpfs                   /dev/shm                tmpfs   rw,size=4000m   0 0      

参考:

oracle启动报错:ORA- 00845: MEMORY_TARGET not supported on this system

今天启动oracle的时候,报错

[[email protected] ~]#su - oracle

[[email protected] ~]$lsnrctl start

lsnrctl: error while loading shared libraries: /u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied

解决办法:在root用户下执行以下命令

[[email protected] ~]# setenforce 0

[[email protected] ~]#su - oracle

[[email protected] ~]$lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 20-SEP-2012 19:03:03

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                20-SEP-2012 19:03:04

Uptime                    0 days 0 hr. 0 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening Endpoints Summary...

 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

The listener supports no services

The command completed successfully

问题解决。

[[email protected] ~]$ sqlplus / as sysdba

SQL> startup

报错:ORA-00845: MEMORY_TARGET not supported on this system

问题定位:安装数据库时或者修改了参数MEMORY_TARGET或者SGA_TARGET的大小。

 SGA参数的大小超过了操作系统/dev/shm的大小。

 linux安装完后默认/dev/shm为物理内存的一半。

技术背景:linux大内存支持(Very Large Memory)中,使用了shmfs/tmpfs选项,ramfs也可以。

 /dev/shm目录挂载类型为tmpfs,此共享内存用于交换,尤其对于大文件优势明显。

 相对于ramfs,tmpfs的优势在于动态调整物理内存的占用,而ramfs不能调整。

 /dev/shm与swap的区别:shm基于内存的文件系统,swap基于硬盘的文件系统。

解决方法:

1、调整MEMORY_TARGET(11G)或者SGA_TARGET(9i,10G)大小(不建议)。

2、调整/dev/shm的大小。

 修改/etc/fstab,重新mount /dev/shm,然后就可以启动数据库了。

(1)查看/dev/shm 大小

 df -k /dev/shm

 Filesystem 1K-blocks Used Available Use% Mounted on

 tmpfs 4089416 0 4089416 0% /dev/shm

(2)调整/dev/shm大小

 vi /etc/fstab

 #tmpfs /dev/shm tmpfs defaults 0 0

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

(3)重新加载

 umount /dev/shm

 mount /dev/shm

 df -k /dev/shm

(4)登陆测试

 sqlplus / as sysdba

至此问题得到解决。

继续阅读