Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2013531
  • 博文数量: 148
  • 博客积分: 7697
  • 博客等级: 少将
  • 技术积分: 3071
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-10 23:04
个人简介

MiBDP,数据开发、项目团队、数据应用和产品在路上,金融保险、互联网网游、电商、新零售行业、大数据和AI在路上。对数仓、模型、ETL、数据产品应用了解。DTCC 2013演讲嘉宾,曾做过两款大获好评的数据产品平台。知识星球ID:35863277

文章分类
文章存档

2020年(1)

2019年(2)

2017年(2)

2016年(5)

2015年(1)

2014年(1)

2013年(6)

2012年(5)

2011年(24)

2010年(28)

2009年(1)

2008年(6)

2007年(30)

2006年(36)

分类: Oracle

2007-04-26 17:13:40

 ORA-12154: TNS:could not resolve service name的解决方法

今天测试人员在部署新的应用时,应用服务器连接不到数据库
[oracle@localhost admin]$ sqlplus hangan/hangan@hatest
 
SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 26 16:24:35 2007
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
ERROR:
ORA-12154: TNS:could not resolve service name
错误指出客户不能查找到tnsnames.ora文件中所列举的服务。
查错误码显示:
ORA-12154: TNS:could not resolve service name
Cause: Oracle Net could not locate the net service name specified in the tnsnames.ora configuration file.
Action: Perform these steps:
1.      Verify that a tnsnames.ora file exists.
See Also:
for configuration file location information
2.      Verify that there are not multiple copies of the tnsnames.ora file.
3.      In the tnsnames.ora file, verify that the net service name specified in your connect string is mapped to a connect descriptor.
4.      Verify that there are no duplicate copies of the sqlnet.ora file.
5.      If you are using domain names, verify that your sqlnet.ora file contains a NAMES.DEFAULT_DOMAIN parameter. If this parameter does not exist, you must specify the domain name in your connect string.
6.      If you are not using domain names, and this parameter exists, delete it or disable it by commenting it out.
7.      If you are connecting from a login dialog box, verify that you are not placing an "@" symbol before your connect net service name.
8.      Activate client tracing and repeat the operation.
Cause: Oracle Net could not locate the database service name or net service name specified in the directory server.
Action: Perform these steps:
1.      Verify that the database service or net service name entry exists in the directory that this computer was configured to use.
See Also:
for directory setup instructions
2.      Verify that the sqlnet.ora file includes the following entry: NAMES.DIRECTORY_PATH=(ldap, other_naming_methods)
根据文档中的提示第三步3.(1.2没问题了)检查tnsnames.ora文件中的服务名称是否正确的配置,经过检查(SERVICE_NAME = hatest)没有问题(更没有语法错误)
然后按照文档做第4.5步,到第6步时发现问题,sqlnet.ora文件中引用了domain域(注:我们这边没使用域)
[oracle@localhost admin]$ cat sqlnet.ora
# SQLNET.ORA Network Configuration File: /home/oracle/OraHome1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
 
NAMES.DEFAULT_DOMAIN = localdomain
 
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)--这个没问题啦
好了那还等什么编辑该文件把domain干掉。编辑完后赶快tnsping hatest
[oracle@localhost admin]$ tnsping hatest
 TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 26-APR-2007 16:33:39
 Copyright (c) 1997 Oracle Corporation.  All rights reserved.
 Used parameter files:
/home/oracle/OraHome1/network/admin/sqlnet.ora
 Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.248.155)(PORT = 1521))) (CONNECT_DATA = (SID = hatest) (SERVER = DEDICATED)))
OK (30 msec)
没问题通了。在连接数据库
[oracle@localhost admin]$ sqlplus hangan/hangan@hatest
 SQL*Plus: Release 9.2.0.4.0 - Production on Thu Apr 26 16:33:49 2007
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
 
SQL> exit
 
 
 
阅读(33832) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

xxfihm2008-12-02 22:38:49

十分感谢啊!!! 我原来装了oracle9.2的客户端,后来因为要开发oci,就装了服务端里的oci,结果装玩后,一连db,发现竟然连不了~~~ 哈哈,把sqlnet.ora里的注释掉后,果然ok了~~@!!!!

chinaunix网友2008-03-14 13:40:59

顶一个