出现ORA-01034: ORACLE not available 使用PL/SQL连接出现ORA-12514问题

今天本人把看着碍眼的LISTENER_ORCL和ORACLR_CONNECTION_DATA的内容给删掉了,即Oracle服务器端(是我一台windows电脑)的tnsnames.ora文件中下方内容:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

然后没把它放心上,认为没什么影响。

 

后来我重启电脑时,发现PL/SQL连接不了数据库,出现以下错误:

ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务

(服务程序Oracle显示都是正常状态-正在运行,以为是服务器端listener.ora监听器的问题,我改了不知道几次,也都重启了,没解决。。。折腾了大半天)

 

之后尝试在服务器端使用SQL Developer连接,这次出现这个问题:

ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
01034. 00000 -  "ORACLE not available"
*Cause:    Oracle was not started up. Possible causes include the following
           - The SGA requires more space than was allocated for it.
           - The operating-system variable pointing to the instance is
           improperly defined.
*Action:   Refer to accompanying messages for possible causes and correct
           the problem mentioned in the other messages.
           If Oracle has been initialized, then on some operating systems,
           verify that Oracle was linked correctly. See the platform
           specific Oracle documentation.

这里说Oracle没有启动(实际上是启动失败了),难道是服务器端tnsnames.ora删除掉内容的原因?但是我另一台电脑(客户端)使用instantclient的tnsnames.ora就是不需要这些内容的啊!

还是决定一试,把删除的内容恢复回来并重启。我去,可以正常连接了。。。

 

下面是我经测试,可以正常连接的最简配置内容:

服务器端listener.ora:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 主机名(推荐)或IP)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

注:SID_LIST_LISTENER可以不用配(有人说9i版本起就可以省略,本人使用的是12c)

服务器端tnsnames.ora:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

注:ORACLR_CONNECTION_DATA可省,但LISTENER_ORCL必须得有

客户端tnsnames.ora:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 服务端主机名或IP)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

注:客户端不需要LISTENER_ORCL和ORACLR_CONNECTION_DATA,SERVICE_NAME的值根据情况改

你可能感兴趣的:(出现ORA-01034: ORACLE not available 使用PL/SQL连接出现ORA-12514问题)