博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ORA-12560: TNS:protocol adapter error(TNS:协议适配器...
阅读量:7228 次
发布时间:2019-06-29

本文共 4332 字,大约阅读时间需要 14 分钟。

hot3.png

这种问题一般是因为客户端不知道要连那个instance或者不知道要使用哪个TNS Alias

可能的原因1.服务没有起来
下边是Tom的一个Test Case来说明OracleServiceSID服务没有起来的话,是会引起ORA-12560错误的。
[plain] view plaincopyprint?
C:\Documents and Settings\tkyte>sqlplus scott/tiger 
 
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007 
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved. 
 
 
Connected to: 
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production 
With the Partitioning, OLAP and Data Mining options 
 
scott%ORA10GR1> exit 
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production 
With the Partitioning, OLAP and Data Mining options 
 
C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1 
The OracleServiceORA10GR1 service is stopping......... 
The OracleServiceORA10GR1 service was stopped successfully. 
 
 
C:\Documents and Settings\tkyte>sqlplus scott/tiger 
 
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007 
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved. 
 
ERROR: 
ORA-12560: TNS:protocol adapter error 
 
 
Enter user-name: 
ERROR: 
ORA-12560: TNS:protocol adapter error 
 
 
Enter user-name: 
ERROR: 
ORA-12560: TNS:protocol adapter error 
 
 
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus 
 
C:\Documents and Settings\tkyte>net start oracleserviceora10gr1 
The OracleServiceORA10GR1 service is starting.......... 
The OracleServiceORA10GR1 service was started successfully. 
 
 
C:\Documents and Settings\tkyte>sqlplus scott/tiger 
 
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007 
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved. 
 
 
Connected to: 
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production 
With the Partitioning, OLAP and Data Mining options 
 
scott%ORA10GR1><A name=PAGETOP></A> 

C:\Documents and Settings\tkyte>sqlplus scott/tiger

SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options

scott%ORA10GR1> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options

C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1

The OracleServiceORA10GR1 service is stopping.........
The OracleServiceORA10GR1 service was stopped successfully.

C:\Documents and Settings\tkyte>sqlplus scott/tiger

SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

ERROR:

ORA-12560: TNS:protocol adapter error

Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error

Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

C:\Documents and Settings\tkyte>net start oracleserviceora10gr1

The OracleServiceORA10GR1 service is starting..........
The OracleServiceORA10GR1 service was started successfully.

C:\Documents and Settings\tkyte>sqlplus scott/tiger

SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options

scott%ORA10GR1>修改方法:控制面板>管理工具>服务里边把OracleServiceSID起起来

可能的原因2.ORACLE_SID环境变量没有指定(最常见引起ORA-12560问题的原因)
检查方法,命令行(cmd)下,
C:\Documents and Settings\ptian>set oracle_sid
ORACLE_SID=test
ORACLE_SID是sqlplus默认连接的数据库instance,即sqlplus user/pwd连接的instance,如果不指定sqlplus里连接的时候就需要明确@你的instance,eg,sqlplus .
修改方法:在注册表中,HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb10g_home1\ORACLE_SID 需指向你的Instance(eg.orcl);或者在系统的环境变量里加ORACLE_SID项,值为Instance的SID。

可能的原因3.TNS_ADMIN环境变量没有指定

检查方法,命令行(cmd)下,
C:\Documents and Settings\ptian>set TNS_ADMIN
TNS_ADMIN=D:\oracle\product\10.1.0\Db_1\NETWORK\ADMIN
TNS_ADMIN应该返回你的tnsnames.ora所在的目录
修改方法:可以在注册表HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0\TNS_ADMIN或者环境变量中指定。

可能的原因4.ORACLE_HOME环境变量没有指定
和上边的方法类似,检查Oracle_Home环境变量

可能的原因5.tnsnames.ora文件内容不对
A sample:
TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ptian-cn.cn.oracle.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )

Possible fixes for the TNS-12560 include:

 

转载于:https://my.oschina.net/jackguo/blog/174140

你可能感兴趣的文章
mysql的备份脚本
查看>>
linux下mysql的root密码忘记解决方法
查看>>
7.索引的性能分析
查看>>
在 Delphi 下使用 DirectSound (17): 频率均衡效果器 IDirectSoundFXParamEq8
查看>>
文件操作命令一cp 2
查看>>
Multi-Mechanize工程目录结构说明
查看>>
halt
查看>>
标准ACL+扩展ACL+命名ACL
查看>>
Meteor应用的启动过程分析
查看>>
九曲黄河万里沙,浪淘风簸自天涯 — 正则表达式
查看>>
欲哭无泪,联想笔记本性价比
查看>>
很简单的在Ubuntu系统下安装字体和切换默认字体的方法
查看>>
我的友情链接
查看>>
dojo框架用hitch实现函数与上下文的绑定
查看>>
ubuntu编译安装vim7.4
查看>>
python之利用PIL库实现页面的图片验证码及缩略图
查看>>
IP-COM设置×××
查看>>
VPC配置案例
查看>>
十年IT运维谈(五):要专业化还是平台化?
查看>>
分享超级给力的一个外发光Shader
查看>>