今天早上重启数据库出错了:
SQL> startup force
ORA-00845: MEMORY_TARGET not supported on this system
搜索了一下之后,发现是这么回事:
来自Oracle的官方解析是:
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.
简单来说就是 MEMORY_MAX_TARGET 的设置不能超过 /dev/shm 的大小:
SQL> show parameter memory_max_target
704m
而查询/dev/shm的大小
[oracle@oracledb Desktop]$ cat /etc/fstab |grep tmpfs
tmpfs /dev/shm tmpfs defaults 0 0
在redhat系列系统中,/dev/shm的默认值是系统总内存的一半,centos也一样,看来是超了。
因此解决问题的办法有两个:
1、调低MEMORY_MAX_TARGET的值(不建议采用)
SQL>alter system set memory_target=600M scope=spfile ;
2、调高/dev/shm的大小(操作性强)
cat /etc/fstab
tmpfs /dev/shm tmpfs defaults 0 0
修改成-->
tmpfs /dev/shm tmpfs defaults,size=2G 0 0
--只是这里的配置在启动的时候没有生效。
--把tmpfs 重新mount 一下:
# 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))
--设备忙,用fuser处理一下:
# fuser -km /dev/shm
# umount /dev/shm
# mount /dev/shm
# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 7.7G 4.7G 2.7G 64% /
/dev/sda1 194M 30M 155M 17% /boot
/dev/sda2 16G 8.9G 5.5G 63% /home
/dev/sdb1 16G 8.9G 5.5G 63% /home
tmpfs 2.0G 459M 1.6G 23% /dev/shm
重启数据库,一般不建议采用startup force 这种强制方式,最好是shutdown immediate 然后再startup
ok,数据库可以正常工作了。
附Oracle给出的就是上述两个解决方案:
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.