[20170704]JOXSHM_EXT_x files on Linux

lfree發表於2017-07-04

[20170704]JOXSHM_EXT_x files on Linux.txt

--//昨天看連結www.itpub.net/thread-2089507-1-1.html時,發現我的一臺測試機器有1堆檔案在目錄/dev/shm下:

$ ls -l /dev/shm | head
total 724
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:44 JOXSHM_EXT_0_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_10_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_11_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_12_test_30113794
-rwxrwx---  1 oracle11g oinstall 12288 2015-07-08 08:38:45 JOXSHM_EXT_13_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_14_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_15_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_16_test_30113794
-rwxrwx---  1 oracle11g oinstall  4096 2015-07-08 08:38:45 JOXSHM_EXT_17_test_30113794

--//還可以發現這些打頭的檔案:
-rwx------ 1 oracle oinstall   3824 2016-09-02 09:45:42 PESLD_book_4e98004_10218b6900000000
-rwx------ 1 oracle oinstall  40200 2016-09-02 09:45:46 PESLD_book_4e98004_406e246900000000
-rwx------ 1 oracle oinstall   1104 2016-09-02 09:45:48 PESLD_book_4e98004_704f9b7d00000000
-rwx------ 1 oracle oinstall    608 2016-09-02 09:46:17 PESLD_book_4e98004_9001327d00000000
-rwx------ 1 oracle oinstall   2096 2016-09-02 09:45:46 PESLD_book_4e98004_b867926900000000
-rwx------ 1 oracle oinstall   1832 2016-09-02 09:45:48 PESLD_book_4e98004_c06b9f7d00000000
-rwx------ 1 oracle oinstall    720 2017-05-09 11:17:51 PESLD_book_a250003_b8749a7b00000000

$ du -sk /dev/shm
724     /dev/shm
--//佔用空間不大僅僅724K.
--//google,發現如下連線://blog.tanelpoder.com/2014/05/09/what-the-heck-are-the-devshmjoxshm_ext_x-files-on-linux/.
--//按照文章的介紹,test應該對應是sid,而我這個例項早不存在.而裡面存在一堆檔案.我僅僅估計異常關閉資料庫時沒有清理.
--//我透過測試說明情況:

SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> SHOW PARAMETER jit
NAME              TYPE     VALUE
----------------- -------- ------
java_jit_enabled  boolean  TRUE

$ ls -l /dev/shm | wc
    573    4578   49135
--//當前573個!!
SCOTT@book> @ &r/spid
       SID    SERIAL# SPID       PID  P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
        56         11 57854       29          4 alter system kill session '56,11' immediate;

SCOTT@book> SELECT DBMS_JAVA.GETVERSION FROM dual;
GETVERSION
-----------
11.2.0.4.0

$ ls -l /dev/shm | wc
    737    5890   63129

--//你可以發現執行後檔案數量增加了.737-573=164
$ ls -l /dev/shm | grep 2017-07-04 | wc
    164    1312   13994
--//注我喜歡講ls定義別名如下
$ alias ls
alias ls='ls --color=auto --time-style=+"%Y-%m-%d %H:%M:%S"'
--//這樣當天的日期能正常顯示.比較符合國人的顯示時間風格.
--//正好增加164個.

$ ls -l /dev/shm | grep 2017-07-04 | head
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:39 JOXSHM_EXT_0_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:39 JOXSHM_EXT_100_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:39 JOXSHM_EXT_101_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:39 JOXSHM_EXT_102_book_188153859
-rwxrwx--- 1 oracle oinstall   8192 2017-07-04 08:57:39 JOXSHM_EXT_103_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:40 JOXSHM_EXT_104_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:40 JOXSHM_EXT_105_book_188153859
-rwxrwx--- 1 oracle oinstall   8192 2017-07-04 08:57:40 JOXSHM_EXT_106_book_188153859
-rwxrwx--- 1 oracle oinstall   4096 2017-07-04 08:57:40 JOXSHM_EXT_107_book_188153859
-rwxrwx--- 1 oracle oinstall  53248 2017-07-04 08:57:40 JOXSHM_EXT_108_book_188153859

--//正常退出會話後.
$ ls -l /dev/shm | grep 2017-07-04 | wc
    164    1312   13994
--//可以發現依舊存在!!

SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

$ ls -l /dev/shm | grep 2017-07-04 | wc
      0       0       0

--//你可以發現正常關閉這些檔案會消失,或者這些記憶體的東西會回收.這樣可以斷定留下那些是異常關閉資料庫留下的.
--//可以重複測試來證明自己的觀點.

SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

$ ls -l /dev/shm | grep 2017-07-04 |wc
      0       0       0

SYS@book> SELECT DBMS_JAVA.GETVERSION FROM dual;
GETVERSION
-----------
11.2.0.4.0

$ ls -l /dev/shm | grep 2017-07-04 | wc
    145    1160   12360

SYS@book> shutdown abort
ORACLE instance shut down.

$ ls -l /dev/shm | grep 2017-07-04 | wc
    145    1160   12360

--//你可以發現異常關閉這些就留在/dev/shm中,消耗記憶體.估計程式異常kill,應該也是一樣的.當然這些消耗的記憶體並不多,我檢視幾臺
--//發現最大消耗9M.

--//我建議在啟動資料庫前實際上可以刪除這些垃圾的.我全部清除後啟動資料庫一點問題都沒有.當然要注意一些應用也可能使用這部分
--//記憶體,在刪除前要仔細檢視.
--//轉抄官方的介紹:


30.1 Secure Database By Default Changes

The PUBLIC EXECUTE privilege for the DBMS_RANDOM PL/SQL package will be deprecated in future Oracle Database releases
(reference Bug 7591837). Users who need to run this PL/SQL package should be given explicit EXECUTE privileges.

30.2 Stale Native Code Files Are Being Cached

Natively compiled PL/SQL and native code generated by the JIT compiler for Oracle JVM, may be cached in operating system
files. The SHUTDOWN ABORT and SHUTDOWN IMMEDIATE commands do not clean these cached native code files (reference Bug
8527383).

To avoid problems caused by stale files in the cache, clean the files before restarting the database instance. The stale
files that belong to the instance can be identified by name. The name patterns are as follows where sid_name is the
system identifier name:

JOXSHM_EXT_*_sid_name_*
PESHM_EXT_*_sid_name_*
PESLD_sid_name_*

It is advisable to remove stale files as part of a startup script. For example, to clean stale files for the instance
passed to the startup csh script by name on Linux, add the following three lines to the startup script:

rm JOXSHM_EXT_*_$1_*
rm PESHM_EXT_*_$1_*
rm PESLD_$1_*

The location of the native cache depends on the platform. It is defined by the location of files created by the
operating system to implement shm_open requests on that platform. For example, Solaris stores shared memory segments in
/var/tmp/.SHMD and /tmp/.SHMD. Linux stores them in /dev/shm.




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2141564/,如需轉載,請註明出處,否則將追究法律責任。

相關文章