记录一则数据库连接故障ORA-12560,ORA-12518
环境:Win Server 2008 R2 + Oracle 11.2.0.1
故障:客户反映数据库连接不上,本机sysdba和网络连接都连接不上。
一、确认故障
二、排查原因
一、确认故障
1.1 服务器尝试sysdba登录
```
PS C:\Users\Administrator> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 18 09:39:14 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS: 协议适配器错误
<h2 id="1.2">1.2 服务器尝试通过网络连接</h2>
PS C:\Users\Administrator> sqlplus system/oracle@xxoradb
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 18 09:34:01 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12518: TNS: 监听程序无法分发客户机连接
<h1 id="2">二、排查原因</h1>
<h2 id="2.1"> 2.1 ORA-12560错误初步排查原因 </h2>
ORA-12560错误官方说明:
$ oerr ora 12560
12560, 00000, "TNS:protocol adapter error"
// *Cause: A generic protocol adapter error occurred.
// *Action: Check addresses used for proper protocol specification. Before
// reporting this error, look at the error stack and check for lower level
// transport errors. For further details, turn on tracing and reexecute the
// operation. Turn off tracing when the operation is complete.
MOS相关文档:Bequeath connection fails with ORA-12560 on Windows (文档 ID 1986438.1)
可能原因:
> Environmental variables are not set correctly. This is a common issue on Windows.
> The following commands do not show proper settings:
> echo %ORACLE_HOME%
> echo %ORACLE_SID%
> echo %PATH%
解决方法:
> Please do the following:
>
> set ORACLE_HOME= <<<<< enter the Oracle Home path here
> set ORACLE_SID= <<<<< enter the Oracle SID name here
> set PATH=%PATH%; <<<<< add the path of %ORACLE_HOME%/bin <<<<< this is the directory where "sqlplus.exe" exists
> echo %ORACLE_HOME% <<<<< this verifies the Oracle home value
> echo %ORACLE_SID% <<<<< this verifies the Oracle SID value
可是<font color="red">目前情况是,环境变量ORACLE_SID设置没有问题。而Windows环境,ORACLE_HOME并不需要在环境变量中设置,而是在注册表中</font>
关于这个ORACLE_HOME环境变量的问题可参考MOS的另一篇文章:How to Set or Switch Oracle Homes on Windows (Doc ID 969581.1)
由于业务目前已经是中断状态,所以可以重启监听和数据库服务,检查注册表信息,但问题依旧。
这里实际走了弯路,因为sqlplus命令是正常使用的,所以在环境变量方面就没多想PATH的问题。
<h2 id="2.2">2.2 ORA-12518错误排查原因 </h2>
ORA-12518错误官方说明:
$ oerr ora 12518
12518, 00000, "TNS:listener could not hand off client connection"
// *Cause: The process of handing off a client connection to another process
// failed.
// *Action: Turn on listener tracing and re-execute the operation. Verify
// that the listener and database instance are properly configured for
// direct handoff. If problem persists, call Oracle Support.
// *Comment: The problem can be worked around by configuring dispatcher(s)
// to specifically handle the desired presentation(s), and connecting
// directly to the dispatcher, bypassing the listener.
查看当前监听配置文件:
listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-1XXXXXXXXXX)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC521))
)
)
ADR_BASE_LISTENER = D:\app\Administrator
修改监听配置文件加入静态监听配置内容:
listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(GLOBAL_DBNAME = xxoradb)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(SID_NAME = xxoradb)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-1XXXXXXXXXX)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC521))
)
)
ADR_BASE_LISTENER = D:\app\Administrator
重启监听后再测试,发现加入静态监听后可以连接到数据库了,同时服务器上的PL/SQL工具也可以正常连接到数据库了。
C:\Users\Administrator>sqlplus system/oracle@xxoradb
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 18 10:52:24 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
<font color="red">这样,就先解决了客户端网络连接的问题。</font>
<h2 id="2.3">2.3 ORA-12560错误再次排查原因</h2>上面解决了客户端的连接问题,但问题还没有完美解决,因为目前本地sysdba仍然还是无法登陆,依然报错ORA-12560:
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 18 10:59:11 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS: 协议适配器错误
请输入用户名:
<font color="red">这时候就怀疑可能是机器上安装了多个Oracle程序导致,也就是说这个sqlplus命令可能是某个客户端的sqlplus程序,</font>
下面验证下是不是这个情况:
看到Oracle产品目录下,11.2.0文件夹下有多个文件夹存在
D:\app\Administrator\product\11.2.0>dir
驱动器 D 中的卷没有标签。
卷的序列号是 0A43-E08A
D:\app\Administrator\product\11.2.0 的目录
2016/01/26 12:26 .
2016/01/26 12:26 ..
2016/01/26 12:35 client_1
2016/01/26 12:23 dbhome_1
2016/01/26 12:25 dbhome_2
0 个文件 0 字节
5 个目录 200,137,936,896 可用字节
看起来的确安装有多个Oracle软件,从命名规则来看,应该是1个客户端,两个DB。
查看当前系统注册表中ORACLE_HOME的值为`D:\app\Administrator\product\11.2.0\dbhome_1`
那么我们使用的sqlplus程序是不是这个路径下的呢?
进一步查看系统环境变量PATH的值,
D:\app\Administrator\product\11.2.0\client_1\BIN;D:\app\Administrator\product\11.2.0\dbhome_1\BIN;D:\app\Administrator\product\11.2.0\dbhome_1;C:\Program Files (x86)\Common Files\NetSarang;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
<font color="red">果然第一个查找路径是客户端的,不是我们想要的服务端程序路径,第二个路径才是。</font>
现在问题就明朗了,我们把客户端的这个路径`D:\app\Administrator\product\11.2.0\client_1\BIN;`删掉。
然后重新打开cmd,发现已经可以正常sysdba登录
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 18 11:16:53 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
最后,再确认下,PL/SQL等工具也可以重新正常登录。至此,问题完美解决。
记录一则数据库连接故障ORA-12560,ORA-12518的更多相关文章
- oracle的listener.ora sqlnet.ora tnsnames.ora三个文件的关联性
学习:http://www.cnblogs.com/william-lee/archive/2010/10/20/1856261.html 之前因为安装的是windows server 2008 r2 ...
- listener.ora/sqlnet.ora/tnsnames.ora配置文件详解
oracle网络配置 三个配置文件 listener.ora.sqlnet.ora.tnsnames.ora ,都是放在$ORACLE_HOME/network/admin目录下. 英文说明: The ...
- ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
不论是单实例还是RAC,对于非缺省端口下(1521)的监听器,pmon进程不会将service/instance注册到监听器,即不会实现动态注册.与单实例相同,RAC非缺省端口的监听器也是通过设置参数 ...
- oracle的sqlnet.ora,tnsnames.ora,listener.ora三个配置文件
总结: 1 .三个配置文件都是放在$ORACLE_HOME\network\admin目录下. 2 .sqlnet.ora确定解析方式 3 .listener.ora上设SID_NAME,通常用于JD ...
- oracle的sqlnet.ora , tnsnames.ora , Listener.ora 文件的作用(转)
oracle网络配置三个配置文件 listener.ora.sqlnet.ora.tnsnames.ora ,都是放在$ORACLE_HOME/network/admin目录下.1. sqlnet.o ...
- oracle错误(ORA:12154 ORA:01034 和 ORA:27101 ORA-18008 ORA-01081)
按照正常操作流程,启动项目,发现项目报错,原因是连接不上oracle数据库, PLSQL连接时报错,错误码 ORA:12154 无法解析指定的连接标识符 第一次,遇到这个错误,在网上找了资料都是需要 ...
- 随笔记录 MBR扇区故障系统备份与还原 2019.8.7
系统备份: [root@localhost ~]# mkdir /abc [root@localhost ~]# mount /dev/sdb1 /abc [root@localhost ~]# dd ...
- 随笔记录 grub引导故障修复 2019.8.7
系统备份: [root@localhost ~]# mkdir /abc [root@localhost ~]# mount /dev/sdb1 /abc [root@localhost ~]# dd ...
- ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的.在Oracle中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务 ...
随机推荐
- c#中abstract与virtua、overridel的用法
1.abstract 抽象方法 ,virtual 虚方法 ,override 重载函数 父类A.m() 子类B.m() abstract的方法父类可以不实现,让子类去重写(重写=overwrite ...
- *HDU 1007 计算几何
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Window平台Grmon下如何使用gdb进行调试
Window平台Grmon下如何使用gdb进行调试 1输入cmd命令,打开其窗口,进入你要执行的文件目录下 2.连接开发板,输入grmon –altjtag –u 3.连上后,输入gdb命令 4.再输 ...
- ABP理论学习之领域服务
返回总目录 本篇目录 介绍 IDomainService接口和DomainService类 样例 创建一个接口 服务实现 调用应用服务 一些讨论 何不只使用应用服务 如何强制使用领域服务 介绍 领域服 ...
- Why MVC is Better?(翻译)
(本文翻译自CodeProject上的一篇关于ASP.NET MVC的文章,原文地址:http://www.codeproject.com/Articles/821275/Webforms-vs-MV ...
- Unicode编码解码在线转换工具
// Unicode编码解码在线转换工具 Unicode 是基于通用字符集(Universal Character Set)的标准来发展,并且同时也以书本的形式(The Unicode Standar ...
- SqlServer2008到期升级企业版 密钥+图解
最近使用SQL Server2008,结果Sql Server Management Studio提示过期了,如图: 遇到如上图情况,需要将SQL Server2008升级维护下,还是输入原来的密钥就 ...
- 【原】安装Win7和Ubuntu双系统后,Win7耳机无声音的解决办法
最近安装了Ubuntu的桌面版,作成了双系统,可是发现了一个问题:进入Win7后有时插耳机会没有声音,外放有声音.后来更新驱动也没有解决问题,最后在网上查到了解决办法. 产生原因:进入Ubuntu后, ...
- AngularJs之一
在讲正题之前,先说一下有关angular简介方面的信息: 1. angularJS 诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用 ...
- salesforce 零基础学习(四十五)Approval Lock & UnLock相关注意事项
我们都知道,当一条记录进入审批流程以后会自动加锁,apex提供Approval类的lock和unlock方法可以让我们使用代码对记录进行加锁和解锁. 项目中遇到一个需求,需要当某种情况下对记录进行先解 ...