当前位置: 代码迷 >> Oracle管理 >> ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME,该如何解决
  详细解决方案

ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME,该如何解决

热度:527   发布时间:2016-04-24 06:17:20.0
ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME
oracle是11g,我在服务器上部署web程序直接连本机数据库,

tnsnames.ora文件
# tnsnames.ora Network Configuration File: D:\app\Administrator\product\11.1.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

LISTENERBOB =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.90)(PORT = 1521))
  )
  (CONNECT_DATA =
  (Service_Name = orcl)
  (SID = orcl) 
  )
  )
listener.ora文件内容
# listener.ora Network Configuration File: D:\app\Administrator\product\11.1.0\db_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.

LISTENERIT =
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.90)(PORT = 1521))
  )

SID_LIST_LISTENERIT =
  (SID_LIST =
  (SID_DESC =
  (GLOBAL_DBNAME = Oracle8)
  (ORACLE_HOME = D:\app\Administrator\product\11.1.0\db_1)
  (SID_NAME = ORCL)
  )
  )


一直报 “ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME” 错误,以前曾经可以过,好久没动,居然不行了,于是我把监听和net服务全部重新配置了,


------解决方案--------------------
LISTENERBOB = 
(DESCRIPTION = 
(ADDRESS_LIST = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.90)(PORT = 1521)) 

(CONNECT_DATA = 
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)



------解决方案--------------------
SQL code
listener.ora文件内容改成如下:SID_LIST_LISTENER =  (SID_LIST =    (SID_DESC =      (SID_NAME = PLSExtProc)      (ORACLE_HOME = D:\app\Administrator\product\11.1.0\db_1)      (PROGRAM = extproc)    )    (SID_DESC =      (GLOBAL_DBNAME = ORCL)      (ORACLE_HOME = D:\app\Administrator\product\11.1.0\db_1)      (SID_NAME = ORCL)    )  )LISTENER =  (DESCRIPTION_LIST =    (DESCRIPTION =      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))    )    (DESCRIPTION =      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.90)(PORT = 1521))    )  )--tnsnames.ora内容:LISTENERBOB =  (DESCRIPTION =    (ADDRESS_LIST =      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.90)(PORT = 1521))    )    (CONNECT_DATA =      (SERVICE_NAME = ORCL)    )  )
------解决方案--------------------
先在system用户下查一下你的数据库实例名是否为“orcl”?:
 
select value$ from sys.props$ where name='GLOBAL_DB_NAME';
------解决方案--------------------
show parameter service_names
另外看看INIT.ORA文件里有service_names这一项吗?它的值是否等于ORCL
当然前提必须如楼上所说的你要确认名为ORCL的数据库实例存在