Oracle 11g侦听器失败,并出现ORA-12514和ORA-12505错误


17

我在开发计算机上本地运行Oracle 11g实例,并且可以直接通过SqlPlus连接到本地实例:

c:\>sqlplus ace

SQL*Plus: Release 11.2.0.2.0 Production on Mon Mar 11 11:50:20 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta

SQL> select count(*) from my_table ;

  COUNT(*)
----------
      5297

但是我无法通过侦听器连接到它:

c:\>sqlplus -L "user/pw@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))"

SQL*Plus: Release 11.2.0.2.0 Production on Mon Mar 11 11:52:40 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

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


SP2-0751: Unable to connect to Oracle.  Exiting SQL*Plus

同样,如果我通过SqlDeveloper连接,则会收到一个错误(尽管ORA-12505, TNS:listener does not currently know of SID given in connect descriptor)。

直到今天(星期一早上),此实例一直稳定运行了一年或更长时间。我们公司的IT有时有时会在周末推送新的策略和更新,因此我假设情况有所变化,但是我无法解决问题。

我已经多次重新启动了服务和侦听器,侦听器日志未提供任何线索。

侦听器似乎很好:

c:\>lsnrctl status

LSNRCTL for 32-bit Windows: Version 11.2.0.2.0 - Beta on 11-MAR-2013 11:55:33

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Beta
Start Date                11-MAR-2013 11:17:30
Uptime                    0 days 0 hr. 38 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File         C:\oraclexe\app\oracle\diag\tnslsnr\FBC305BB46560\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=machine.domain.com)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

1521端口似乎还可以:

c:\>netstat -an -O | find /i "1521"
  TCP    0.0.0.0:1521           0.0.0.0:0              LISTENING       4368
  TCP    169.243.90.109:55307   159.185.207.100:1521   ESTABLISHED     12416
  TCP    [::]:1521              [::]:0                 LISTENING       4368

(PID 4368是TNSLSNR.exe进程。)

另外,我可以tnsping去XE服务:

c:\>tnsping xe

TNS Ping Utility for 32-bit Windows: Version 11.2.0.2.0 - Beta on 11-MAR-2013 12:27:47

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = machine.domain.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (210 msec)

listenerr.ora文件中:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = machine.domain.com)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

另外,我不知道它是否相关,我似乎无法访问顶点https://127.0.0.1:8080/apex(即使该权限似乎还不错)。

那么我还应该去哪里呢?

使用请求的信息进行更新

SQL> show parameter service_names

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      XE
SQL> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string

UPDATE2:如@ miracle173正确地指出,听者罚款。使用更新的“ local_listener”参数,现在可以显示更多信息:

Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=machine.domain.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

您的INSTANCE_NAME初始化参数和ORACLE_SID环境变量的值是什么?您的数据库由于某种原因未在默认侦听器中注册。尝试发出alter system register;,然后重新连接到数据库。
Yasir Arsanukaev 2013年

@YasirArsanukaev instance_name是'xe'(如果相关,请使用小写字母),并且我没有ORACLE_SID环境变量。
切片2013年

3
两个注意事项:“侦听器似乎很好”:我不这样认为,因为它没有显示名为“ XE”的服务“我可以ping通XE服务”:tnsping连接到侦听器,但它不会打扰服务。因此,您只能显示侦听器是否已启动并正在运行,而不能使用ist检查侦听器是否已注册服务。因此,如果侦听器正在端口上运行,则tnsping“(DESCRIPTION =(ADDRESS =(PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XE)))”将成功1521的本地主机,即使该服务不存在。
miracle173

我今天遇到了同样的问题,正如@ miracle173所述,alert.log中有一个注册。Oracle在VM上运行。事实证明,在VM上,主机名和主机名.domain都指向与127.0.0.1(localhost)不同的IP地址。修改主机文件(Windows \ system32 \ drivers \ etc)以强制进行映射后,现在一切都很好。

改变寄存器解决了这个问题..谢谢:)
user116258

Answers:


15

因此,感谢@YasirArsanukaev投入的时间,我找到了一个可行的解决方案,但我无法真正解释。

考虑到这个LOCAL_LISTENER想法,我正在阅读另一个回答,它说:

数据库使用LOCAL_LISTENER参数来标识应向其注册的侦听器。默认情况下为null,根据文档,其等效于主机名:1521。

因此,我尝试对自己的主机名执行ping操作,但无法这样做-看起来有些IPv6问题,收到了常规失败消息。

所以我从那个答案中得到了建议

SQL> alter system set LOCAL_LISTENER='(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' scope=both;
SQL> alter system register;

并且现在可以正常运行,大概是因为它可以解析本地主机引用,而无法解析实际的主机名。


1
您实际上已经提出了解决方案:将数据库自动注册为默认的LOCAL_LISTENER ='(ADDRESS = {PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))'(其中主机名是计算机的网络名称)无法工作,因为使用此名称无法到达机器。可能在alert.log或某些sqnlnet.log(%ORACLE_HOME%/ network / log /)中有一个有关数据库注册问题的
条目

@Unsliced实际上,我遇到了同样的问题,因为使用的服务ID删除了“ .Domain.local”后缀文本,因此我的问题已解决。
2015年

运行两个alter语句为我解决了tns listner错误消息,并且我能够连接
smartexpert 2016年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.