Fault handling Ora-12162:tns:net service name is incorrectly specified

Source: Internet
Author: User
Tags reserved sqlplus
Fault handling Ora-12162:tns:net service name is incorrectly specified

This article will give you a case of ORA-12162 error caused by not setting the system environment variable ORACLE_SID. I hope you have some thoughts.

1. Obtain general presentation information about ORA-12162 error information
[Oracle@asdlabdb01 ~]$ oerr ora 12162
12162, 00000, "tns:net service name is incorrectly specified"
*cause:the Connect descriptor corresponding to the "NET service name in
TNSNAMES. ORA or in the directory server (Oracle Internet directory) is
Incorrectly specified.
*action:if using local naming make sure there are no syntax errors in
The corresponding connect descriptor in the TNSNAMES. ORA file. If using
Directory naming check the information provided through the administration
Used for directory naming.

2. Failure phenomenon
The failure described in this article differs from this generic problem description, and there is no problem with the connection string connections recorded in Tnsnames.ora in the database server, but if no connection string is specified, a ORA-12162 error is reported.

1 using the system user to try to log on, you will receive the following error message
[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 Use SYSDBA Identity login will get the same error message
[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 But at this point, if the use of service names to connect to the database, can be successful, which is the problem of the strange phenomenon.
[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

System@ora10g>

Imagine that your goal is to quickly enter the database for maintenance operations, but at this time the login is encountering obstacles, it will feel very awkward. What's even more maddening is that if you use the connection string to log on to the database at this time, the result will be a more brutal situation: The database will not start because it cannot log on properly.

3. Fault Reason
The reason behind the bizarre fault is that it is the basis: Oracle_sid not specified.
Confirm the system's current oracle_home and ORACLE_SID environment variables
[Oracle@asdlabdb01 ~]$ Echo $ORACLE _home
/oracle/app/oracle/product/10.2.0/db_1
[Oracle@asdlabdb01 ~]$ Echo $ORACLE _sid

[Oracle@asdlabdb01 ~]$

Visible, only the ORACLE_HOME environment variable is set, but Oracle_sid is empty at this point, which is the real reason for the problem.

4. Fault Handling
Give the Oracle_sid and try to login again.
[Oracle@asdlabdb01 ~]$ Export oracle_sid=ora10g
[Oracle@asdlabdb01 ~]$ Echo $ORACLE _sid
ora10g
[Oracle@asdlabdb01 ~]$ 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

Sys@ora10g>

OK, now the problem is handled.

5. Summary
What is the enlightenment of this case to us?
1 The system default error message sometimes does not have reference value. And, in some cases, these false hints can also be misleading. The reason is simple, the system default error message can not include all the symptoms;
(2) Any system-level setup problem may cause the database system to appear abnormal;
3 We need to be calm when we are in trouble. Sometimes we may need to check the original information, don't take it for granted.

Suggestion: In order to avoid the problems mentioned in the article, first, you can write the environment variables such as ORACLE_SID to the system profile, but need to ensure the validity of the content of the system profiles; Each time you log on to the database server to manually complete the database environment variables specified, this method although the keyboard to increase the tapping, but it is more intuitive and more secure.

Good luck.

Secooler
10.08.27

--The end--

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.