1

我很好地安装了 Oracle 11g r2,有 2 个数据库(se3 和 mydb,两者都有 db_domain .orcl 即 mydb.orcl 和 se3.orcl)运行良好,直到昨天。但突然我收到 ORA-12514 错误(TNS:listener 不知道连接描述符中请求的服务)..

我的 tnsnames.ora 文件:

# tnsnames.ora Network Configuration File: G:\oracledb\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

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


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

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb.orcl)
    )
  )

SE3 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = se3.orcl)
    )
  )

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

LISTENER.ORA FILE:
# listener.ora Network Configuration File: G:\oracledb\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = G:\oracledb\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:G:\oracledb\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = G:\oracledb

我能够很好地“tnsping mydb/se3”.. 也尝试更改 tnsnames.ora 和 listener.ora 文件(现已恢复),但无法通过 sqlplus 或 sqldeveloper/visual studio 连接到其中任何一个.. 请帮助我。 。 谢谢!

4

2 回答 2

0

根据您自己的评论“我能够设置 ORACLE_SID 但无法通过 sqlplus ... ORA-01034 - Oracle 不可用”,您的数据库实例可能已关闭。理论上可以运行底层 Windows 服务 OracleServiceMYDB 并在进程中运行相应的 oracle.exe,但数据库实例已关闭。最好的办法是在服务器上查找包含 alert_mydb.log 的跟踪目录并查看最后的条目。

如果数据库根本没有运行并且警报日志显示没有严重错误,请像这样启动它:

set ORACLE_SID=MYDB
set ORACLE_HOME=D:\my\oracle\home

%ORACLE_HOME%\bin\sqlplus "/ as sysdba"
ORACLE not available.
SQL> STARTUP 
SQL> EXIT

lsnrctl services

最后一个命令应该显示 MYDB 已注册。继续 ORACLE_SID=SE3

于 2013-09-19T18:17:02.570 回答
0

就我而言,我在尝试通过SQL*Plus仅客户端计算机连接到远程数据库时收到ORA-12514错误:

C:\Temp>sqlplus username@connect_descriptor

SQL*Plus: Release 11.2.0.3.0 Production on Wed Sep 24 09:43:04 2014

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

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

我觉得这很令人费解,因为tnsping响应成功:

C:\Temp>tnsping connect_descriptor

TNS Ping Utility for 32-bit Windows: Version 11.2.0.3.0 - Production on 24-SEP-2
014 09:48:04

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

Used parameter files:
D:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host
.intranet.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =
HOST13)))
OK (20 msec)

最终,我在tnsnames.ora文件SERVICE_NAME中发现我的问题是不正确的值:

CONNECT_DESCRIPTOR =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = host.intranet.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = HOST13)
    )
  )

HOST13(通过普通文本编辑器)更改为 的正确值SERVICE_NAME后,我能够连接到远程 Oracle 数据库。

在我的 Oracle 11.2 客户端机器上,这里是tnsnames.ora的位置:

C:\Oracle\product\11.2.0\client_1\network\admin\tnsnames.ora
于 2014-09-24T15:06:18.250 回答