ORA-12162: TNS:net service name is incorrectly spe

故障现象

1)使用system用户尝试登录系统,此时便会收到报错如下信息

[oracle@asdlabdb01 ~]$ sqlplus system/sys

SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:02 2010
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:


2)使用sysdba身份登陆会得到同样的错误信息

[oracle@asdlabdb01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:48 2010
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:


3)但此时,如果使用服务名方式连接数据库,是可以成功的,这也是该问题现象的诡异之处。

[oracle@asdlabdb01 ~]$ sqlplus system/sys@ora10g
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:53:41 2010
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

故障原因

诡异的故障背后的原因竟然是那样的基础:ORACLE_SID没有指定!

确认系统当前的ORACLE_HOME和ORACLE_SID环境变量
[oracle@asdlabdb01 ~]$ echo $ORACLE_HOME
/oracle/app/oracle/product/10.2.0/db_1
[oracle@asdlabdb01 ~]$ echo $ORACLE_SID
[oracle@asdlabdb01 ~]$
可见,此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。

你可能感兴趣的:(ORA-12162: TNS:net service name is incorrectly spe)