今天数据库启动时出现了ORA-00845: MEMORY_TARGET not supported on this system
官方错误原因描述:
ORA-00845: 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.
官方解决版本如下:
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(shm) 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.
大概的意思是:这个问题是由于设置SGA或MEMORY_MAX_TARGET 的大小超过了操作系统/dev/shm的大小,Oracle在metalink的文档:Doc ID:Note:460506.1中进行了说明。
数据库安装前配置时,在文件/etc/sysctl.conf 中修改了如下的内核参数
- # Controls the maximum shared segment size, in bytes
- kernel.shmmax = 536870912
Linux中系统内核正在使用的shared memory大小查看,通过/etc/sysctl.conf 的注释知道该参数默认以byte为单位
- cat /proc/sys/kernel/shmmax
- 536870912
以M为单位计算共享内存大小
也就是等于512M
- echo 536870912/1024/1024 | bc 512
查看Oracle数据库sga和memory max
- SQL> show parameter sga
- NAME TYPE VALUE
- ------------------------------------ ----------- -------lock_sga boolean FALSE
- pre_page_sga boolean FALSE
- sga_max_size big integer 1584M
- sga_target big integer 0
- SQL> show parameter memory
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- hi_shared_memory_address integer 0
- memory_max_target big integer 1584M
- memory_target big integer 1584M
- shared_memory_address integer 0
1584M远超过了操作系统共享内存大小512M
解决这个问题可以从两个层面(数据库和操作系统):
1.数据库层面:修改初始化参数,使得初始化参数中sga或者memory的设置小于/dev/shm的大小
- alter system set memory_max_target=480M
使得数据库共享内存小于操作系统共享内存大小
2.操作系统层面:调整/dev/shm的大小
- vim /etc/sysctl.conf
- # Controls the maximum shared segment size, in bytes
- kernel.shmmax = 68719476736
①修改shammax值,增大系统上的共享内存大小
- sysctl -p
内核参数立即生效
或者②修改/dev/shm的大小可以通过修改/etc/fstab来实现:
查看/dev/shm的空间大小
- #df -h /dev/shm/
- Filesystem Size Used Avail Use% Mounted on
- tmpfs 2.0G 1.3G 696M 65% /dev/shm
- # vim /etc/fstab
- tmpfs /dev/shm tmpfs defaults 0 0
- tmpfs /dev/shm tmpfs defaults,size=10240M 0 0
重新挂载/dev/shm,再次查看/dev/shm的空间大小
- #mount -o remount /dev/shm
- #df -h /dev/shm/
- Filesystem Size Used Avail Use% Mounted on
- tmpfs 10G 1.3G 8.8G 13% /dev/shm
再次启动数据库问题解决!
本文出自 “老徐的私房菜” 博客,谢绝转载!