ORA-12162: TNS:net service name is incorrectly specified
今天在进行修改oracle_sid环境变量的时候,将相关的环境变量值去掉,从而不能进入sqlplus,报错如下:
[oracle@kel ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 8 19:19:21 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR:
ORA-12162: TNS:net service name is incorrectly specified Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified Enter user-name:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
查看错误信息:
[oracle@kel ~]$ 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.
错误信息里描述的是:指定的连接字符串错误,服务名称出错,从而使用netmgr命令来检查连接字符串的正确性:
[oracle@kel ~]$ netmgr
在这里可以测试连接字符串是否出错,但是在这里我测试是失败的,从而查看1521端口是否启动监听:
[oracle@kel ~]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:37667 0.0.0.0:* LISTEN 5140/ora_d000_orcl
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
从而可以看到1521端口未启动监听,从而查看监听的状态:
[oracle@kel ~]$ lsnrctl status LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 08-JUN-2014 19:31:45 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
在这里看到监听是未启动的状态,从而打开数据库监听:
[oracle@kel ~]$ lsnrctl start LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 08-JUN-2014 19:31:49 Copyright (c) 1991, 2005, Oracle. All rights reserved. Starting /home/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /home/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=kel)(PORT=1521))) Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 08-JUN-2014 19:31:50
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /home/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=kel)(PORT=1521)))
The listener supports no services
The command completed successfully
再次测试,发现是可以成功连接的,从而利用连接字符串来连接服务器:
[oracle@kel ~]$ sqlplus system/orcl@orcl SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 8 19:34:53 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
发现使用连接字符串是可以连接数据库的,再次使用本地进行连接发现还是不可以的,如下:
[oracle@kel ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 8 19:45:49 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR:
ORA-12162: TNS:net service name is incorrectly specified
最后查看环境变量ORACLE_SID的值:
[oracle@kel ~]$ echo $ORACLE_SID [oracle@kel ~]$
发现环境变量未设置,从而导致连接出错,将ORACLE_SID设置为数据库实例名称:
[oracle@kel ~]$ export ORACLE_SID=orcl
[oracle@kel ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jun 8 19:48:51 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options SQL>
当将环境变量ORACLE_SID的值设置为正确的值的时候,发现已经可以连接。
ORA-12162: TNS:net service name is incorrectly specified的更多相关文章
- 【故障处理】ORA-12162: TNS:net service name is incorrectly specified (转)
本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-12162错误的案例.希望大家有所思考. 1.获得有关ORA-12162报错信息的通用表述信息 [oracle@asdlabdb ...
- 【故障处理】ORA-12162: TNS:net service name is incorrectly specified
本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-12162错误的案例.希望大家有所思考. 1.获得有关ORA-12162报错信息的通用表述信息[oracle@asdlabdb0 ...
- Oracle案例05——ORA-12162: TNS:net service name is incorrectly specified
最近在梳理环境,发现环境真的不是一般的复杂,配置不是一般的乱,刚在梳理环境的时候发现一个库通过conn /as sysdba无法连接,具体处理过程如下: 一.错误信息 [oracle@ ~]$ sql ...
- 登录RMAN 报告ORA-12162:TNS:net service name is incorrectly specified错
登录RMAN 报告ORA-12162:TNS:net service name is incorrectly specified错 [oracle@localhost admin]$ date Tue ...
- sqlplus登录提示:ORA-12162:TNS:net service name is incorrectly specified错误
[root@localhost ~]# su - oracle [oracle@localhost ~]$ sqlplus '/as sysdba' SQL*Plus: Release 11.2.0. ...
- plsql 连接oralce数据库,报ora 12557 tns 协议适配器不可加载错误
使用plsql 连接oracle 数据库报ora 12557 错误: 解决方案: 1:首先确保服务中的service以及监听器都开启 2:F:\app\Administrator\product\11 ...
- ORA-12546: TNS: 权限被拒绝(ORA - 12546 TNS: Permission Denied)
这个问题上网一查大都是说权限之类的问题,本人在经过第二次折腾之后发现,其实是自己的Oracle客户端工具在破解过程中被自己用防火墙禁止访问网络了,自己还在另一篇博文里记录过,竟然忘光了,BS一下自己! ...
- ORACLE 数据库管理
[故障处理]ORA-12162: TNS:net service name is incorrectly specified 本文将给大家阐述一个因未设置系统环境变量ORACLE_SID导致ORA-1 ...
- linux 安装oracle
报错1:报display相关错误su - oracleDISPLAY=redhat64-2:1 --此处为远程会话地址(可以写localhost或IP均可)export DISPLAYcd /home ...
随机推荐
- URLEncode转json
http://tool.chinaz.com/tools/urlencode.aspx?jdfwkey=zobsn2 http://www.bejson.com/
- Android:打包apk
右击项目->导出export next,完成相关信息填写将得到.apk文件,即可部署到手机上. 第一次: 然后打开目录就可以看到生成的apk,可以发布到各大市场上.
- 通过数据库表自动生成POJO(JavaBean)对象
主类: package bqw.tool; import java.util.ResourceBundle;import java.sql.DriverManager;import java.sql. ...
- [原创]使用命令行工具提升cocos2d-x开发效率(一)之TexturePacker篇
TexturePacker是一个常用的制作sprite sheet的工具,它提供了很多实用的功能. 一般我们制作sprite sheet都是使用他的gui版本,纯手工操作,就像下面这张图示的一样. 刚 ...
- ActiveMQ集群(2)
ActiveMQ具有强大和灵活的集群功能,但在使用的过程中会发现很多的缺点,ActiveMQ的集群方式主要有两种:Master-Slave和Broker Cluster. 1.Master-Slave ...
- 在BSP的.bat文件下設置全局變量方法
用于多個產品共用一個BSP的時候,在BSP的.bat文件中設置全局變量,去掉不需要加載的驅動和不同點是很好的方法. 一,舉例:BSP中.bat的一段code: set BSP_SMDK2443=1 s ...
- [HDOJ4578]Transformation(线段树,多延迟标记)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 四种操作:查询.加法.乘法.改数.应该是需要维护三个lazy标记,然后就是套路了.查询是区间内所 ...
- 设置mysql的interactive_timeout和wait_timeout的值
1,为什么要重新设置这两个变量的值? 因为如果数据库默认这两个变量的值是8小时(即28800秒)如果在8小时之内没有连接到数据库,等下次再连的时候就会抛连接超时,或连接关闭这样的异 常,但是多连接几次 ...
- UVa 10817 (状压DP + 记忆化搜索) Headmaster's Headache
题意: 一共有s(s ≤ 8)门课程,有m个在职教师,n个求职教师. 每个教师有各自的工资要求,还有他能教授的课程,可以是一门或者多门. 要求在职教师不能辞退,问如何录用应聘者,才能使得每门课只少有两 ...
- [转]ASP.NET数据库连接字符串总结
这个不难,而且很重要,但总忘,找了篇比较全的,作为资料. 原文链接http://developer.51cto.com/art/201107/275406.htm 关于数据库链接字符串的相关知识,我们 ...