ORACLE常見報錯之:ORA-00845: MEMORY_TARGET not supported on this system
1、 問題的提出
報錯如下:
[oracle@night ~]$ sqlplus /nologSQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 15:39:40 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.SQL> conn sys/ as sysdbaEnter password:Connected to an idle instance.SQL> startupORA-00845: MEMORY_TARGET not supported on this systemSQL>
2、 問題的解釋
在官方文檔中,有好多地方提到這個錯誤,可以通過官方文檔進一步的瞭解這個報錯的解釋,以便於更快更準確更透徹的解決問題
開啟官方文檔的error messages標籤,可以看到有關錯誤碼的解釋
-
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.
或者利用官方文檔的搜尋功能,搜尋錯誤碼,也可以找到相應的解釋和解決辦法
Setting Memory Target at Instance Startup on Linux
Starting with Oracle Database 11g Release 1 (11.1), Oracle provides the option of automatically managing SGA and PGA with a combined MEMORY_TARGET
parameter without having to set SGA_TARGET
and PGA_AGGREGATE_TARGET
explicitly. This is supported on Linux, Windows, Solaris, HPUX, and AIX (reference Bug 7258378).
If you see the ORA-00845
error reported on Linux machines at Oracle instance startup when using the MEMORY_TARGET
parameter, then check the size of /dev/shm
. If /dev/shm
is not configured, then mount it sized to be at least the value of MEMORY_TARGET
. If /dev/shm
is configured but the amount of available space reported (through df -k /dev/shm
) is less than MEMORY_TARGET
, then free the space or mount a larger /dev/shm
to satisfy the MEMORY_TARGET
size. Note that if you set theMEMORY_MAX_TARGET
parameter greater than MEMORY_TARGET
, then ensure that /dev/shm
is sized to be at least the value of MEMORY_MAX_TARGET
.
Memory Target for Oracle Database Instances
Running Database Configuration Assistant (DBCA) defaults to this Automatic Memory Management option. In the case of upgrade or manual database creation,MEMORY_TARGET
can be specified in the initialization parameter file.
如上的內容就詳細的解釋了該錯誤是由於/dev/shm小於MEMORY_TARGET的大小,或者是/dev/shm根本就沒有掛載,如果同時設定了MEMORY_TARGET和MENORY_MAX_TARGET,那麼/dev/shm至少必須和MEMORY_MAX_TARGET的大小一致
Insufficient Memory Target Errors
On Linux systems, if the operating system /dev/shm
mount size is too small for the Oracle system global area (SGA) and program global area (PGA), then you encounter the following error:
ORA-00845: MEMORY_TARGET not supported on this system.
The cause of this error is an insufficient /dev/shm
allocation. The total memory size of the SGA and PGA, which sets the initialization parameter MEMORY_TARGET
or MEMORY_MAX_TARGET
, cannot be greater than the shared memory file system (/dev/shm
) on your operating system.
Background
Automatic Memory Management (AMM) has been updated in Oracle ASM 11g Release 2. It manages both the SGA and PGA together. It is managed by the Memory Manager Process (MMAN). In this release, note the following changes to AMM:
It uses MEMORY_TARGET
instead of SGA_TARGET
It uses MEMORY_MAX_TARGET
instead of SGA_MAX_SIZE
(defaults to MEMORY_TARGET
)
It uses memory allocated by /dev/shm
If the value of max_target
is set to a value greater than the allocation for the /dev/shm
size, then you may encounter the error ORA-00845: MEMORY_TARGET not supported on this system.
Note:
An ORA-00845 error can also occur if
/dev/shm
is not properly mounted. To rule out this possibility, run the command
df -k
to ensure that
/dev/shm
is mounted. For example:
$ df -k Filesystem 1K-blocks Used Available Use% Mounted on shmfs 6291456 832356 5459100 14% /dev/shm
Solution
Increase the /dev/shm
mountpoint size.
For example:
# mount -t tmpfs shmfs -o size=7g /dev/shm
To make this change persistent across system restarts, add an entry in /etc/fstab
similar to the following:
shmfs /dev/shm tmpfs size=7g 0
如上的內容不僅講出了錯誤的原因,而且還大概的說了一下在oracle 11g中的自動記憶體管理,並且給出了該錯誤的解決的命令
3、問題的深入探究,到底什麼是 /dev/shm
首先來看一下linux系統中已經掛載的檔案系統
[oracle@night ~]$ df -Th檔案系統 類型 容量 已用 可用 已用% 掛載點/dev/sda2 ext3 16G 11G 3.9G 74% //dev/sda3 ext3 1.6G 37M 1.4G 3% /tmp/dev/sda1 ext3 99M 12M 83M 13% /boottmpfs tmpfs 252M 0 252M 0% /dev/shm
可以看出我已經掛載了/dev/shm,但是該分區的檔案系統並不是普通的檔案系統類型,而是tmpfs檔案系統類型,那麼什麼是tmpfs格式的檔案系統類型呢?
tmpfs是linux的一種臨時檔案系統,它的大小是不固定的,預設的大小是實際記憶體的一半。
[root@night ~]# free -m total used free shared buffers cachedMem: 503 368 134 0 26 283-/+ buffers/cache: 58 444Swap: 2525 0 2525[root@night ~]# df -Th /dev/shm/檔案系統 類型 容量 已用 可用 已用% 掛載點tmpfs tmpfs 252M 0 252M 0% /dev/shm[root@night ~]#
預設的掛載點是/dev/shm,/dev/shm其實就是一個目錄,所以tmpfs也可以掛載到一個自訂的目錄。
[root@night ~]# file /dev/shm//dev/shm/: sticky directory[root@night ~]# ll -d /dev/shm/drwxrwxrwt 2 root root 40 07-25 21:43 /dev/shm/[root@night ~]#
tmpfs可以使用系統記憶體,也可以使用swap,所以我可以把tmpfs的size適當的調高一點。
由於tmpfs是存在於記憶體中的,所以在卸載tmpfs或者是關機重啟linux作業系統的時候,tmpfs的內容就會丟失。
tmpfs是基於記憶體的,而swap是基於磁碟的,所以兩者是不同的,而且tmpfs的IO很高。
4、解決問題
前面已經知道了報錯是由於/dev/shm過小導致的,而且/dev/shm是一個tmpfs的檔案系統,該檔案系統是基於記憶體的,大小是隨著實體記憶體的大小動態改變的,一般為實體記憶體的一半;tmpfs檔案系統可以使用物理內容,也可以使用swap。
那麼根據這麼內容,來處理問題
首先看一下實體記憶體和swap的大小
[root@night ~]# free -m total used free shared buffers cachedMem: 503 369 134 0 26 283-/+ buffers/cache: 58 444Swap: 2525 0 2525[root@night ~]#
由上可知道,RAM為500M左右,SWAP為2G
修改tmpfs大小,用root使用者
[root@night ~]# vim /etc/fstab
內容如下
LABEL=/ / ext3 defaults 1 1LABEL=/tmp /tmp ext3 defaults 1 2LABEL=/boot /boot ext3 defaults 1 2tmpfs /dev/shm tmpfs defaults,size=1G 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0LABEL=SWAP-sda5 swap swap defaults 0 0~
重新掛載/dev/shm
[root@night ~]# umount /dev/shm/[root@night ~]# mount /dev/shm/[root@night ~]# mount/dev/sda2 on / type ext3 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)/dev/sda3 on /tmp type ext3 (rw)/dev/sda1 on /boot type ext3 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)none on /proc/fs/vmblock/mountPoint type vmblock (rw)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)tmpfs on /dev/shm type tmpfs (rw,size=1G)[root@night ~]# df -Th /dev/shm/檔案系統 類型 容量 已用 可用 已用% 掛載點tmpfs tmpfs 1.0G 0 1.0G 0% /dev/shm[root@night ~]#
現在重新啟動oracle服務切換oracle使用者)
[oracle@night ~]$ df -Th /dev/shm/檔案系統 類型 容量 已用 可用 已用% 掛載點tmpfs tmpfs 1.0G 0 1.0G 0% /dev/shm[oracle@night ~]$ sqlplus /nologSQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 22:05:01 2013Copyright (c) 1982, 2009, Oracle. All rights reserved.SQL> conn sys/ as sysdbaEnter password:Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 418484224 bytesFixed Size 1336932 bytesVariable Size 281020828 bytesDatabase Buffers 130023424 bytesRedo Buffers 6103040 bytesDatabase mounted.Database opened.SQL> !lsnrctl startLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-JUL-2013 22:07:06Copyright (c) 1991, 2009, Oracle. All rights reserved.Starting /u01/app/oracle/product/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionSystem parameter file is /u01/app/oracle/product/network/admin/listener.oraLog messages written to /u01/app/oracle/diag/tnslsnr/night/listener/alert/log.xmlListening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=night)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date 25-JUL-2013 22:07:15Uptime 0 days 0 hr. 0 min. 30 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/network/admin/listener.oraListener Log File /u01/app/oracle/diag/tnslsnr/night/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=night)(PORT=1521)))The listener supports no servicesThe command completed successfullySQL> !ps -ef | grep thinkdbaoracle 4117 1 0 22:06 ? 00:00:00 ora_pmon_thinkdbaoracle 4119 1 0 22:06 ? 00:00:00 ora_vktm_thinkdbaoracle 4123 1 0 22:06 ? 00:00:00 ora_gen0_thinkdbaoracle 4125 1 0 22:06 ? 00:00:00 ora_diag_thinkdbaoracle 4127 1 0 22:06 ? 00:00:00 ora_dbrm_thinkdbaoracle 4129 1 0 22:06 ? 00:00:00 ora_psp0_thinkdbaoracle 4131 1 0 22:06 ? 00:00:00 ora_dia0_thinkdbaoracle 4133 1 1 22:06 ? 00:00:01 ora_mman_thinkdbaoracle 4135 1 0 22:06 ? 00:00:00 ora_dbw0_thinkdbaoracle 4137 1 0 22:06 ? 00:00:00 ora_lgwr_thinkdbaoracle 4139 1 0 22:06 ? 00:00:00 ora_ckpt_thinkdbaoracle 4141 1 0 22:06 ? 00:00:00 ora_smon_thinkdbaoracle 4143 1 0 22:06 ? 00:00:00 ora_reco_thinkdbaoracle 4145 1 1 22:06 ? 00:00:01 ora_mmon_thinkdbaoracle 4147 1 0 22:06 ? 00:00:00 ora_mmnl_thinkdbaoracle 4149 1 0 22:06 ? 00:00:00 ora_d000_thinkdbaoracle 4151 1 0 22:06 ? 00:00:00 ora_s000_thinkdbaoracle 4186 4066 2 22:06 ? 00:00:02 oraclethinkdba (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))oracle 4192 1 0 22:06 ? 00:00:00 ora_qmnc_thinkdbaoracle 4208 1 1 22:06 ? 00:00:00 ora_cjq0_thinkdbaoracle 4210 1 0 22:06 ? 00:00:00 ora_q000_thinkdbaoracle 4212 1 0 22:06 ? 00:00:00 ora_q001_thinkdbaoracle 4214 1 0 22:06 ? 00:00:00 ora_vkrm_thinkdbaoracle 4222 1 29 22:07 ? 00:00:17 ora_j002_thinkdbaoracle 4231 1 5 22:07 ? 00:00:03 ora_j006_thinkdbaoracle 4237 1 4 22:07 ? 00:00:02 ora_j007_thinkdbaoracle 4250 4066 0 22:08 pts/1 00:00:00 /bin/bash -c ps -ef | grep thinkdbaoracle 4252 4250 0 22:08 pts/1 00:00:00 grep thinkdbaSQL>
啟動成功了
查看memory_target的大小
SQL> show parameter memoryNAME TYPE VALUE------------------------------------ ----------- ------------------------------hi_shared_memory_address integer 0memory_max_target big integer 400Mmemory_target big integer 400Mshared_memory_address integer 0SQL>
已經符合官方文檔的說明了,/dev/shm大於memory_max_target的大小。
本文出自 “night ★linux營運|| DBA” 部落格,請務必保留此出處http://thinkdba.blog.51cto.com/7492507/1257103