记录一则数据库连接故障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 实例提供服务注册,并响应来自客户端对该服务 ...
随机推荐
- SQL基本语句汇总
语句:CREATE TABLE 作用:创建表格 格式:CREATE TABLE tableName (columnName1 columnDataType1, columnName2 columnDa ...
- error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
zabbix3.2启动有如下报错: # service zabbix_server startStarting zabbix_server: /home/zabbix-server/sbin/zab ...
- 输出 n=6 的三角数字阵(JAVA基础回顾)
package itcast.feng; import java.util.Scanner; //需求:输出 n=6 的三角数字阵 //1 //2 3 //4 5 6 //7 8 9 10 //11 ...
- 系列篇|编译可在Android上运行的依赖库(一):glib库
前言 这是系列文章,它们由<编译可在Android上运行的glib库>及其他4篇文章组成,这4篇文章在“编译依赖库”一节中列出.由于glib库依赖于其他第三方库,所以需要先将依赖的第三方库 ...
- 日志系统实战(二)-AOP动态获取运行时数据
介绍 这篇距上一篇已经拖3个月之久了,批评自己下. 通过上篇介绍了解如何利用mono反射代码,可以拿出编译好的静态数据.例如方法参数信息之类的. 但实际情况是往往需要的是运行时的数据,就是用户输入等外 ...
- 【Java并发编程实战】-----“J.U.C”:ReentrantLock之二lock方法分析
前一篇博客简单介绍了ReentrantLock的定义和与synchronized的区别,下面跟随LZ的笔记来扒扒ReentrantLock的lock方法.我们知道ReentrantLock有公平锁.非 ...
- SQL Server AlwaysOn
标签:SQL SERVER/MSSQL SERVER/数据库/DBA/高性能解决方案 概述 环境: 域服务器:windows server 2008 R2 SP1,192.168.2.10 DNS:1 ...
- 单独使用jdbc编程问题总结(一)
在学习Mybatis之前,我们先来回顾JDBC编程的相关知识.在此基础上深入的学习Mybatis框架.如有错误,敬请指正. (一)首先我们既然要使用jdbc,当然是要操作数据库了.创建一个名为:myb ...
- jquery中bind()绑定多个事件
bind()绑定事件 $(selector).bind(event,data,function): 参数event为事件名称(如"click,mouseover....."),da ...
- PMO是什么?如何与其他部门协作配合提高项目成功率?
许多公司里,有许多IT项目,特别是在软件公司里,许多开发团队并没有运用灵敏开发来进行项目办理.在某些状况下,尤其在一些公司里IT不是很受注重的,只能作为一个事务支撑部分,灵敏团队面对的首要疑问,是缺少 ...