1. 程式人生 > >ORA-12162: TNS:net service name is incorrectly specified 錯誤解決

ORA-12162: TNS:net service name is incorrectly specified 錯誤解決

mini 使用 cti 感到 連接數 post ini sql bit

本文將給大家闡述一個因未設置系統環境變量ORACLE_SID導致ORA-12162錯誤的案例。

希望大家有所思考。

1.故障現象

本文所要描寫敘述的故障與這個通用的問題描寫敘述不同,在數據庫server端使用TNSNAMES.ORA中記錄的連接串連接沒有問題。但如若未指定連接串,將會報出ORA-12162錯誤。

1)使用system用戶嘗試登錄系統,此時便會收到報錯例如以下信息
[[email protected] ~]$ 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身份登陸會得到相同的錯誤信息
[[email protected] ~]$ 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)但此時,假設使用服務名方式連接數據庫,是能夠成功的。這也是該問題現象的詭異之處。

[[email protected] ~]$ sqlplus [email protected]

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

[email protected]
/* */>
想象一下,你的目標是高速的進入到數據庫中進行維護操作,但此時登錄都遭遇障礙,會感到很的別扭。

更讓人抓狂的是。假設此時使用連接串登錄到數據庫進行停起操作。結果將會處於更加慘烈境況:數據庫將由於無法正常登錄導致無法啟動數據庫。



2.故障原因

詭異的故障背後的原因居然是那樣的基礎:ORACLE_SID沒有指定!


確認系統當前的ORACLE_HOME和ORACLE_SID環境變量

[[email protected] ~]$ echo $ORACLE_HOME
/oracle/app/oracle/product/10.2.0/db_1
[[email protected] ~]$ echo $ORACLE_SID

[[email protected] ~]$

可見,此時僅僅設置了ORACLE_HOME環境變量。但ORACLE_SID此時為空,這就是該問題的真實原因。



3.故障處理

給出ORACLE_SID。又一次嘗試登錄。
[[email protected] ~]$ export ORACLE_SID=ora10g
[[email protected] ~]$ echo $ORACLE_SID
ora10g
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 23:27:34 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

[email protected]>


OK,此時問題處理完成。


ORA-12162: TNS:net service name is incorrectly specified 錯誤解決