ORA-12154: TNS:could not resolve service name / TNS-03505: Failed to resolve name

一个新建立的数据库,连接不上提示如下错误:

$ sqlplus system/admin@tt9a

SQL*Plus: Release 9.2.0.1.0 - Production on Mon Feb 23 21:53:35 2009

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve service name

用tnsping检测:

$ tnsping tt9a

TNS Ping Utility for IBM/AIX RISC System/6000: Version 9.2.0.1.0 - Production on 23-FEB-2009 21:52:59

Copyright (c) 1997 Oracle Corporation. All rights reserved.

Used parameter files:
/xxx/oraxxx/db/tech_st/10.2.0/network/admin/xxx/sqlnet_ifile.ora

TNS-03505: Failed to resolve name
$

怎么会有

Used parameter files:
/xxx/oraxxx/db/tech_st/10.2.0/network/admin/xxx/sqlnet_ifile.ora

------------------------------------------------

检查环境变量,居然有TNS_ADMIN:

TNS_ADMIN=/xxx/oraxxx/db/tech_st/10.2.0/network/admin/xxx

但当前Oracle 用户并没有设置TNS_ADMIN

--------------------

解决方法一(值标):尝试设置一个新的值替换掉原来的TNS_ADMIN定义:

TNS_ADMIN=/u01/ora9a/product/9.2/network/admin;export TNS_ADMIN

解决方法二(值本):

找到什么地方设置了这个TNS_ADMIN,在root用户下,

# env|grep TNS_ADMIN

TNS_ADMIN=/xxx/oraxxx/db/tech_st/10.2.0/network/admin/xxx

发现有这个配置,寻找root用户的相关环境变量/etc/profile及/.profile都没有发现这个配置,一般地,系统的环境变量就在这两个位置,怎么没有?

到/etc/下find 这个TNS_ADMIN

发现还有一个文件/etc/environment中有这个配置,后来找相关资料查证了下,AIX下读取环境变量的顺序是/etc/profile-->/etc/environment--->用户的 profile-->用户的.env(如果用户的profile中有设置ENV=$HOME/.env)

以前还没有遇到这样的情况,留下吧,方便!

[@more@]
请使用浏览器的分享功能分享到微信等