[20141128]目錄/var/tmp/oracle.txt

lfree發表於2014-11-28

[20141128]目錄/var/tmp/oracle.txt

--昨天幫別人解決監聽問題,使用者整理機器,刪除了/var/tmp/oracle目錄裡面的檔案(估計已經刪除很久了),導致執行lsnrctl status報錯。
--我自己以前也遇到一次,記憶比較深刻,今天在自己機器上測試重複錯誤。

SYS@test> @ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.3.0     Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

# lsof | grep /var/tmp/.oracle
tnslsnr   18430 oracle11g   10u     unix 0x000001002550d680                53579 /var/tmp/.oracle/s#18430.1
tnslsnr   18430 oracle11g   11u     unix 0x000001002550d380                53581 /var/tmp/.oracle/sEXTPROC1521
tnslsnr   18430 oracle11g   12u     unix 0x000001002576c980                53583 /var/tmp/.oracle/s#18430.2
--可以發現監聽使用這些檔案。

$ cd /var/tmp/.oracle
$ mkdir laji
$ ls -l
total 4
drwxr-xr-x  2 oracle11g oinstall 4096 2014-11-28 11:22:01 laji
srwxrwxrwx  1 oracle11g oinstall    0 2014-09-09 11:38:28 s#18430.1
srwxrwxrwx  1 oracle11g oinstall    0 2014-09-09 11:38:28 s#18430.2
srwxrwxrwx  1 oracle11g oinstall    0 2014-07-15 09:33:42 s#5027.1
srwxrwxrwx  1 oracle11g oinstall    0 2014-07-15 09:33:42 s#5027.2
srwxrwxrwx  1 oracle11g oinstall    0 2014-09-09 11:38:28 sEXTPROC1521

-- 對比前面的發現s#5027.*這兩個檔案,可能是某一次當機或者斷電,沒有清除留下的檔案。據對方講裡面很多檔案,使用版本10.2.0.3,監聽
-- 中斷了許多次,估計是遇到bug之類的問題。

--首先移動檔案。
$ mv s* laji/

# lsof | grep /var/tmp/.oracle
tnslsnr   18430 oracle11g   10u     unix 0x000001002550d680                53579 /var/tmp/.oracle/s#18430.1
tnslsnr   18430 oracle11g   11u     unix 0x000001002550d380                53581 /var/tmp/.oracle/sEXTPROC1521
tnslsnr   18430 oracle11g   12u     unix 0x000001002576c980                53583 /var/tmp/.oracle/s#18430.2
bash      18634 oracle11g  cwd       DIR                8,3      4096     472369 /var/tmp/.oracle
--奇怪,這些檔案並沒有標識delete。
--這個時候外面的使用者是可以連上資料庫的。

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-NOV-2014 11:28:52
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hisdg)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory

--可以發現報錯。

$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-NOV-2014 11:29:46
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hisdg)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory

--執行lsnrctl stop也一樣。

--執行跟蹤看看。

$  strace -f -o /tmp/aaa.txt lsnrctl status

--檢視跟蹤可以發現:
$ grep  '\/var\/tmp/\.oracle' /tmp/aaa.txt
20352 access("/var/tmp/.oracle", F_OK)  = 0
20352 chmod("/var/tmp/.oracle", 01777)  = 0
20352 access("/var/tmp/.oracle/s#18430.2", F_OK) = -1 ENOENT (No such file or directory)
20352 access("/var/tmp/.oracle/sEXTPROC1521", F_OK) = -1 ENOENT (No such file or directory)

$ grep  "No such file or directory" /tmp/aaa.txt
20352 connect(5, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20352 connect(5, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20352 access("/var/tmp/.oracle/s#18430.2", F_OK) = -1 ENOENT (No such file or directory)
20352 access("/var/tmp/o/s#18430.2", F_OK) = -1 ENOENT (No such file or directory)
20352 access("/var/tmp/.oracle/sEXTPROC1521", F_OK) = -1 ENOENT (No such file or directory)
20352 access("/var/tmp/o/sEXTPROC1521", F_OK) = -1 ENOENT (No such file or directory)

--很明顯就是這些檔案給刪除了。如何解決呢?

1.方法1:
直接kill -9 tnslsnr 程式,在重啟監聽就可以了。

2.方法2:

$ file laji/s#18430.1
laji/s#18430.1: socket

--這個是socker型別檔案,能否重新建立呢?查詢相關文件。必須使用root使用者建立

# cd /var/tmp/.oracle
# mksock sEXTPROC1521
# mksock s#18430.2
# mksock s#18430.1

# ls -l
total 4
drwxr-xr-x  2 oracle11g oinstall 4096 2014-11-28 11:27:34 laji
srwxr-xr-x  1 root      root        0 2014-11-28 11:48:30 s#18430.1
srwxr-xr-x  1 root      root        0 2014-11-28 11:47:09 s#18430.2
srwxr-xr-x  1 root      root        0 2014-11-28 11:46:56 sEXTPROC1521
# chown oracle:oinstall s*
# chmod 777 s*
# ls -l
total 4
drwxr-xr-x  2 oracle11g oinstall 4096 2014-11-28 11:27:34 laji
srwxrwxrwx  1 oracle    oinstall    0 2014-11-28 11:48:30 s#18430.1
srwxrwxrwx  1 oracle    oinstall    0 2014-11-28 11:47:09 s#18430.2
srwxrwxrwx  1 oracle    oinstall    0 2014-11-28 11:46:56 sEXTPROC1521

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-NOV-2014 11:50:09

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hisdg)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

--依舊不行。

# lsof | grep /var/tmp/.oracle  --加一個head
COMMAND     PID      USER   FD      TYPE             DEVICE      SIZE       NODE NAME
tnslsnr   18430 oracle11g   10u     unix 0x000001002550d680                53579 /var/tmp/.oracle/s#18430.1
tnslsnr   18430 oracle11g   11u     unix 0x000001002550d380                53581 /var/tmp/.oracle/sEXTPROC1521
tnslsnr   18430 oracle11g   12u     unix 0x000001002576c980                53583 /var/tmp/.oracle/s#18430.2

--很明顯方法2不行。應該這些檔案與原來建立聯絡,自己建立的沒有關聯。移動回來。

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-NOV-2014 12:03:25

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hisdg)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                09-SEP-2014 11:38:28
Uptime                    80 days 0 hr. 24 min. 56 sec
Trace Level               off
Security                  ON: Password or Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle11g/product/11.2.0/db_2/network/admin/listener.ora
Listener Log File         /u01/app/oracle11g/diag/tnslsnr/hisdg/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xxxxx)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "b.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test.com" has 2 instance(s).
  Instance "test", status UNKNOWN, has 1 handler(s) for this service...
  Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB.com" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_DGB.com" has 2 instance(s).
  Instance "test", status UNKNOWN, has 1 handler(s) for this service...
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_DGMGRL.com" has 1 instance(s).
  Instance "test", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

--看來以後刪除檔案,要先使用lsof確定這些檔案是否處於開啟狀態。比如有些開啟的檔案,如果你刪除了,這些空間並不會回收。

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

相關文章