MEMORY_TARGET參數在Oracle 11g被引進,主要是用於控制Oracle對於系統記憶體的使用,首次將SGA與PGA整合到一起實現自動管理。一旦設定了MEMORY_TARGET參數值,Oracle會根據需要自動調整SGA與PGA以合理的分配及使用記憶體。但如果MEMORY_TARGET設定不當,就容易引起ORA-00845,因為MEMORY_TARGET與/dev/shm(tempfs)息息相關,本文即是對由此引發問題的描述。
1、故障現象
[oracle@linux1 catadb]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 13 21:38:41 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
idle> startup nomount;
ORA-00845: MEMORY_TARGET not supported on this system
2、故障分析
[oracle@linux1 trace]$ oerr ora 00845
00845, 00000, "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.
#從上面的描述可知,/dev/shm的大小應該至少是當前系統每一個執行個體的SGA_MAX_SIZE,個人認為這個描述不是很準確
#下面查看警示日誌
[oracle@linux1 trace]$ more alert_catadb.log
Wed Nov 13 21:38:48 2013
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
1073741824 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 901312512 and used is 161312768 bytes.
Ensure that the mount point is /dev/shm for this directory. memory_target needs larger /dev/shm
#警示日誌給出了比較精確的描述,/dev/shm至少是1GB,因為我們的參數檔案中定義的MEMORY_TARGET為1GB
#同時也給出了/dev/shm當前已使用的和剩餘空間的大小。剩餘空間大小901312512不夠1GB,因此需要考慮增加dev/shm或減少MEMORY_TARGET的值
#延伸思考
/dev/shm實際上就是對應到tmpfs,也可以稱之為臨時檔案系統(不是塊裝置)。有點類似於Oracle資料庫的暫存資料表空間一樣啊,用於加速和最佳化系統。
我們可以通過df -h來查看到該載入點,該目錄並不位於磁碟,而是在記憶體裡,預設情況下,其大小為當前記憶體的一半,該檔案系統會被自動載入。
/dev/shm的分配是按需分配,如我們前面的錯誤描述,當前分配了1GB,實際使用了154MB,剩餘860MB。也就是說這860MB依舊可分配給其他應用程式。
使用tmps檔案系統有一些優點,可以實現動態檔案系統大小,其次是由於駐留記憶體,可以閃電加速。重啟後被清空,也就是相當於快閃記憶體。
#當前系統的/dev/shm
[oracle@linux1 trace]$ df -h | grep shm
tmpfs 1014M 154M 860M 16% /dev/shm
[oracle@linux1 ~]$ ls -hltr /dev/shm
total 154M
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:06 ora_+ASM1_2686978_68
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:06 ora_+ASM1_2686978_39
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:06 ora_+ASM1_2686978_40
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:06 ora_+ASM1_2686978_41
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:06 ora_+ASM1_2686978_42
...............
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:47 ora_+ASM1_2686978_66
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:47 ora_+ASM1_2686978_52
-rw-r----- 1 grid oinstall 4.0M Nov 14 11:47 ora_+ASM1_2686978_67
更多詳情見請繼續閱讀下一頁的精彩內容:
ORA-01172、ORA-01151錯誤處理
ORA-00600 [2662]錯誤解決
ORA-01078 和 LRM-00109 報錯解決方案
ORA-00471 處理方法筆記
ORA-00314,redolog 損壞,或丟失處理方法
ORA-00257 歸檔日誌過大導致無法儲存的解決辦法