想来很多同学都曾幸与ORA-12154结缘过吧?!遥想当年ORA-12154令人那样的无措憋屈无可奈何是那样的记忆犹新!!
恰逢今天有同学遇到ORA-12154了,就估且借此把分析处理过程小总结下吧!!
OK,下面咱先来看看人家Oracle的官方定义,以表深刻理解问题的实质!
Cause: A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured. For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.
Action:
- If you are using local naming (TNSNAMES.ORA file): - Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA) - Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible. - Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file. - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or stray characters. Errors in a TNSNAMES.ORA file may make it unusable. - If you are using directory naming: - Verify that "LDAP" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA). - Verify that the LDAP directory server is up and that it is accessible. - Verify that the net service name or database name used as the connect identifier is configured in the directory. - Verify that the default context being used is correct by specifying a fully qualified net service name or a full LDAP DN as the connect identifier - If you are using easy connect naming: - Verify that "EZCONNECT" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA). - Make sure the host, port and service name specified are correct. - Try enclosing the connect identifier in quote marks. See the Oracle Net Services Administrators Guide or the Oracle operating system specific guide for more information on naming. |
好,前面我们已经知道了为什么Oracle丢这么个错误码给我们,这里做下简单的翻译:
当我们尝试通过某个连接标识符连接oracle,而这个标识符不能被oracle正确解析为可用的连接时,这个error就出现了!
OK!那接下来我们就遵循这个错误码的本质原因检查分析排除问题吧!
首先,检查下你的oracle是否正常运行吧!具体来说就是在服务器端检查oracle能否正常连接,在命令行:sqlplus 用户名/密码
其次,检查下你网络吧!确定对于本机访问目标ORACLE安装所在机器是没有问题的(包括端口号,默认为1521)。
这个简单:telnet ip地址 oracle端口号
再次,检查服务器的监听有没有问题(可以先在服务端检查,然后到再客户端检查下)。
1)在服务器在命令行执行:lsnrctl status
2)在客户端在命令行执行:tnsping HSE10_DBEAS
C:\Documents and Settings\Administrator>tnsping HSE10_DBEAS TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 19-11月- 2012 13:41:32 Copyright (c) 1997, 2010, Oracle. All rights reserved. 已使用的参数文件: D:\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora 已使用 TNSNAMES 适配器来解析别名 尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1 68.1.10)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = dbeas))) OK (10 毫秒) |
最后,检查本机连接oracle的配置文件(tnsnames.ora)有没有问题。这个开发人员习惯手工修改这个配置文件,有时候无意之间写错了又会干着急。这个网上有大把的示例可供参考,认真检查下不要搞错就是了,另外要特别留意的是要检查比如配置名称有无不可解析的特殊字符:空格什么的(这类问题一般是比较难于定位的)。所以建议如果不是那么有把握的话,那就乖乖用Net Configuration Assistant配置吧;下面示例可供参考,连接名称HSE10_DBEAS,服务器IP192.168.1.10,数据库实例名dbeas。
HSE10_DBEAS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = dbeas) ) ) |
后语:如果你的oracle是老老实实在新环境安装的,这时候一般都不会有什么问题的啦!有时候可能是你用的连接工具的问题,可以通过sqlplus在命令行下检测连接!
命令行:sqlplus 用户名/密码@NET服务名
如果这时候都还有问题,那就要具体问题具体分析了!
这次就是遇到了这样的问题,貌似前面的所有检查没有问题,客户端通过命令行或PLSQL工具连接无法连接!!
思来想去,判断估计问题出在了注册表或者环境变量。再次详细检查客户端电脑,欣喜发现该同学安装了两个oracle客户端!
没什么好说的,接下来就着手处理吧!
1)处理注册表。备份然后直接把其中一个客户端的注册表信息delete。测试未通过!
2)处理环境变量。备份并处理path环境变量值,去除其中一个客户端的变量!命令行进行连接测试,通过!通过plsql工具连接测试,通过!!
over!