ORA-01034和ORA-27101的解決方法

1 先看oracle的監聽和oracle的服務是否都啓動了。啓動oracle監聽:
cmd的命令行窗口下,輸入lsnrctl start,回車即啓動監聽。


2 查看oracle的sid叫什麼,比如創建數據庫的時候,實例名叫“orcl”,那麼先手工設置一下oralce的sid,cmd命令窗口中,set ORACLE_SID=orcl


3 再輸入sqlplus  /nolog,回車
再輸入 conn / as sysdba;回車


4 再輸入startup,回車.這步是啓動oracle服務。如果startup啓動被告知已經啓動了,可以先輸入shutdown immediate;等shutdown結束之後,再輸入startup。


5 過幾秒鐘等命令運行完成,就能連接了。這個時候,可以輸入"select * from user_tables;"測試一下,看是否有查詢結果。


6 出現ORA-01034和ORA-27101的原因是多方面的:主要是oracle當前的服務不可用,shared memory realm does not exist,是因爲oracle沒有啓動或沒有正常啓動,共享內存並沒有分配給當前實例.所以,通過設置實例名,再用操作系統身份驗證的方式,啓動數據庫。這樣數據庫就正常啓動了,就不會報ORA-01034和ORA-27101兩個啓動異常了。

今天在測試庫上遇到了ORA-27101的錯誤,當通過客戶端連接到db時返回如下:
[oracle@bluerin admin]$ sqlplus system/oracle@test
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Aug 10 11:05:04 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
對於這個問題第一印象,可能會覺得沒有足夠的內存空間,來創建共享內存段
1.首先檢查內核參數設置以及alert.log 文件
fs.file-max = 6553600
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
查看後都沒有問題,主機有足夠的內存,數據庫也已經在啓動狀態:
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
2.之後發現在報錯之後,繼續輸入用戶名和密碼確可以登陸
Enter user-name: system
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
3.查看sqlnet.log日誌
[oracle@bluerin log]$ pwd
/u01/app/product/11.1.0/db_1/network/log
[oracle@bluerin log]$ cat sqlnet.log
Directory does not exist for read/write [/u01/app/product/11.1.0/db_1/log] [/u01/app/product/11.1.0/db_1/log/diag/clients]


***********************************************************************
Fatal NI connect error 12541, connecting to:
 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.201.1.134)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=Oracle8)(CID=(PROGRAM=java@localhost)(HOST=localhost)(USER=oracle))))
  VERSION INFORMATION:
        TNS for Linux: Version 11.1.0.6.0 - Production
        TCP/IP NT Protocol Adapter for Linux: Version 11.1.0.6.0 - Production
  Time: 05-AUG-2010 18:30:51
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12541
    TNS-12541: TNS:no listener
    ns secondary err code: 12560
    nt main err code: 511
    TNS-00511: No listener
    nt secondary err code: 111
    nt OS err code: 0


***********************************************************************
提示找不到listener......
4.檢查listener是否配置正確
[oracle@bluerin alert]$ cat /u01/app/product/11.1.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/product/11.1.0/db_1//network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /u01/app/product/11.1.0/db_1)
      (SID_NAME = siebtest)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.201.1.134)(PORT = 1521))
  )
[oracle@bluerin ~]$ tnsping test
Used parameter files:
/u01/app/product/11.1.0/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.201.1.134)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = siebtest)))
OK (0 msec)
listener 配置沒有問題。。。
5.由於實例已經在啓動的狀態,這時候考慮到實例註冊的問題
SQL> show parameter local_listener
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string
發現local_listener沒有值。。。。。
6.設置local_listener參數
SQL> alter system set local_listener='(ADDRESS =(PROTOCOL=TCP)(HOST=10.201.1.134)(PORT=1521)(SID=siebtest))';


System altered.


SQL> alter system register;


System altered.
7.再次登陸成功
[oracle@bluerin alert]$ sqlplus system/oracle@test
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Aug 10 12:51:11 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
 
 總結:
    如果LOCAL_LISTENER丟失,會導致自動實例註冊失敗,數據庫實例不會識別Listener,當Listener連接
數據庫實例的時候,由於Listener沒有註冊,導致了 ORA-27101: shared memory realm does not exist.
發佈了54 篇原創文章 · 獲贊 113 · 訪問量 53萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章