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.
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页