ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务

Posted

技术标签:

【中文标题】ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务【英文标题】:ORA-12514: TNS:listener does not currently know of service requested in connect descriptor 【发布时间】:2014-02-28 11:39:09 【问题描述】:

我在尝试通过侦听器连接到 Oracle 数据库 XE 时遇到问题:

 sqlplus system/my_password@XE

我收到以下错误:

ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

我使用 Ubuntu 12.10 和 Oracle Express Edition 11g。

我的主要目标是将 java + oracle db 与 jdbc 连接,但我得到了同样的错误。

这是我的 listener.ora

# listener.ora Network Configuration File:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

和 tnsnames.ora

# tnsnames.ora Network Configuration File:

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

lsnrctl service

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 04-FEB-2014 17:01:44
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

【问题讨论】:

您的听众似乎是最近才开始的;如果那是在数据库启动之后,它可能还没有注册,尽管它应该经常重试。但是要检查一下,如果您alter system register,您的服务是否出现在services 列表中?如果没有,您是否设置了local_listener 参数?如果不是默认为服务器的网络名称 - 那么它是否解析为与 watson 相同的 IP,特别是如果您的服务器有多个 IP 地址? 【参考方案1】:

我不得不在 Windows 服务中重新启动我的 OracleServiceXE 服务,它又可以工作了。

【讨论】:

【参考方案2】:

假设即使侦听器已经运行了一段时间,您的数据库也无法注册,听起来您的local_listener 参数没有明确设置,因此您的数据库正在尝试注册on a default address;而且由于它无法注册,因此它使用的任何地址似乎都与侦听器所在的地址不同。

假设watson 正在解析到一个有用的外部 IP 地址,如果您能够从您的框外获取该 TNS 错误,则可能是这种情况,您可以告诉数据库使用相同的地址进行注册:

alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=watson)(PORT=1521))' scope=memory;
alter system register;

如果可行并且lsnrctl services 现在显示XE 并且您对此感到满意,则可以将memory 更改为both 并重新执行so it persists across the next DB restart。

或者,如果您只尝试在同一个框内连接,watson 可能会解决一些无用的问题,例如 127.0.0.1,如果它在您的 /etc/hosts 中设置为这样做的话;或者您的/etc/hosts 地址可能与您的 DNS 条目不一致。您可以将 listener.oratnsnames.ora 更改为“正确的”FQDN 或 IP 地址,只要它与您的数据库认为的网络名称匹配即可。

【讨论】:

【参考方案3】:

tnsnames.ora 很好,它用于 sqlplus 客户端。 listener.ora 不好。输入 lsnrctl service 时缺少 XE 服务 很难相信你必须设置 listener.ora 才能安装 Oracle express。

这是我的测试虚拟机的示例。

Service "PEXPROC" has 1 instance(s).
  Instance "PEXPROC", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
Service "ocmdb" has 1 instance(s).
  Instance "ocmdb", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:29 refused:0
         LOCAL SERVER
The command completed successfully

我在 listener.ora 中的示例片段

SID_LIST_LISTENER_OCM =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ocmdb)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = ocmdb)
    )
  )

【讨论】:

以上是关于ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务的主要内容,如果未能解决你的问题,请参考以下文章

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

ORA-12514: TNS:listener does not currently know of service requested in connect

ORA-12514: TNS: listener does not currently know of service requested in connect descriptor

ORA-12514 TNS listener does not currently know of service re

plsql登录提示ORA-12514:TNS:listener does not currently know of service…………