oracle在使用tnsping时,老是提醒:TNS-03505: 无法解析名称? admin 2023-09-20 11:24:01 篇首语:本文由小编为大家整理,主要介绍了oracle在使用tnsping时,老是提醒:TNS-03505: 无法解析名称?相关的知识,希望对你有一定的参考价值。 使用tnsping测试oracle是否安装成功时,老是提醒:TNS-03505: 无法解析名称?,但sqlplus和plsql都能连上,请问谁知道是什么原因,对使用数据库有什媚暌拱响吗? 求辅佐解答! 参考技术A 得安装了oracle 输入tnsping 才有用的若是没有安装oracle, 会提醒 不是内部或外部呼吁!至于有啥输出提醒,你得电脑若是装了oracle的话可以在呼吁行直接输入tnsping看能输出啥? 参考技术B 之前的使用参数文件是oracle客户端的 所以会无法解析名称 我想问的是呈现这种情形 sqlplus好使 对建的库和用户有没有影响啊 参考技术C TNS-03505: Failed to resolve name Cause: The service name you provided could not be found in TNSNAMES.ORA, an Oracle Names server, or a native naming service.Action: Verify that you entered the service name correctly. You may need to ensure that the name was entered correctly into the network configuration 参考技术D 得安装了oracle 输入tnsping 才有用的若是没有安装oracle, 会提醒 不是内部或外部呼吁!至于有啥输出提醒,你得电脑若是装了oracle的话可以在呼吁行直接输入tnsping看能输出啥? 第5个回答 2013-07-07 只输入 tnsping 的话,有什么输出提醒呢? 来谈谈tnsping 目前很多Oracle的爱好者希望快速搭建一套Oracle 数据库并通过客户端开发工具进行开发和应用连接。但是,我们也注意到,很多用户遇到的不是安装数据库本身,而是安装之后无法远程连接到数据库。并且,遇到各种各样的TNS报错,无从下手。这里,我们希望通过博客的方式,来展现一下网络连接方面的基本配置和诊断方法。就从tnsping开始吧!首先,我们要了解的是: 什么是tnsping?可以参考官方文档的具体介绍http://docs.oracle.com/cd/E11882_01/network.112/e41945/connect.htm#NETAG378tnsping 实际上就是一个小工具,用来决定是否一个Oracle Net 网络服务(service)可以被接受。从某种意义上来说,tnsping 针对的 sqlnet连接,就好比为我们常用的ping 命令来检查IP,主机名网络连接情况。我们来做一个有趣的试验:先来看看以下配置信息:数据库所在服务器端:数据库安装到Linux服务器,hostname = ttdev, IP 地址= 192.168.56.11, ORACLE_SID=ORCL------[oracle@ttdev ~]$ cat /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.oraLISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521)) ) )SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (PROGRAM = extproc) (SID_NAME = PLSExtProc) (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2) ) )ADR_BASE_LISTENER = /home/oracle/app/oracle/------客户端:在Windows ,安装oracle 客户端后,配置Windows 环境变量 TNS_ADMIN 指向 C:appliyangproduct11.2.0client_2etworkadmin在该路径下,添加 tnsnames.ora 文件------TTORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )------客户端的sqlnet.ora 使用默认SQLNET.AUTHENTICATION_SERVICES = (NTS) =============试验一:首先,我们来看一下数据库服务器端的实际情况:通过putty 登录到Linux系统的oracle 用户,停掉数据库,并检查监听情况:------[oracle@ttdev ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.1.0.7.0 - Production on Tue Mar 25 18:49:23 2014Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> quitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@ttdev ~]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-MAR-2014 18:52:03Copyright (c) 1991, 2010, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.11)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.2.0 - ProductionStart Date 25-MAR-2014 18:14:27Uptime 0 days 0 hr. 37 min. 36 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.oraListener Log File /home/oracle/app/oracle/diag/tnslsnr/ttdev/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.11)(PORT=1521)))Services Summary...Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... 《=========服务里面并没有ORCL,因为数据库刚刚被shutdown了!The command completed successfully------在Windows 客户端, 开始 菜单=》 运行 =》 输入 cmd 命令,进入dos 窗口,并输入 tnsping TTORCL, 返回------C:Usersliyang>tnsping TTORCLTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 10:06:08Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.ora已使用 TNSNAMES 适配器来解析别名尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1 《=====TNSPING 仍然解析成功,返回TTORCL的具体内容!68.56.11)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))OK (20 毫秒)------上面返回的 “尝试连接” 后面部分是sqlnet 如何解析到的TTORCL 别名,或者叫 连接标识符。该别名的解析是通过客户端的 TNS_ADMIN指定路径下的 sqlnet.ora文件中的 NAMES.DIRECTORY_PATH 参数决定的。上面的试验结果显示的是通过 TNSNAMES 适配器 来解析成功的。 该请求可以看到,是通过 TCP 的网络协议 (PROTOCOL = TCP), 连接到了 IP地址为 192.168.56.11 上的服务器(也可以是主机名),希望连接的端口为 1521, 服务名为 (SERVICE_NAME = orcl)。连接20毫秒的意思是 一个预估的大概网络传输往返一次的时间。以上测试说明了,不论数据库是否运行,只要监听存在并在运行,tnsping 都可以成功解析! ============= 试验二:停止数据库实例,更改监听的端口为 1522 , 启动监听:------[oracle@ttdev admin]$ sqlplus / as sysdbaSQL*Plus: Release 11.1.0.7.0 - Production on Tue Mar 25 21:07:28 2014Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> quitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@ttdev admin]$ ps -ef | grep smonoracle 4335 3326 0 21:08 pts/1 00:00:00 grep smon 《====没有数据库实例进程运行[oracle@ttdev admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-MAR-2014 21:08:00Copyright (c) 1991, 2010, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.11)(PORT=1522))) 《====端口已经更改!STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.2.0 - ProductionStart Date 25-MAR-2014 21:01:31Uptime 0 days 0 hr. 6 min. 29 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.oraListener Log File /home/oracle/app/oracle/diag/tnslsnr/ttdev/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.11)(PORT=1522))) 《======监听1522 正常运行 Services Summary...Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... 《====没有监听到 ORCL的服务The command completed successfully------接下来,回到客户端,执行 tnsping ttorcl------C:Usersliyang>tnsping ttorclTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 12:09:48Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.ora已使用 TNSNAMES 适配器来解析别名尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1 <===仍然返回成功解析和接受68.56.11)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))OK (0 毫秒)------这个试验二证明了,tnsping 即使在数据库实例停止的情况下,并没有监听1521端口,只要监听运行,tnsping就可以返回正常!=============试验三:那我们再来测试一下,监听停止的情况------[oracle@ttdev ~]$ lsnrctl stopLSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-MAR-2014 19:26:31Copyright (c) 1991, 2010, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.11)(PORT=1521)))The command completed successfully[oracle@ttdev ~]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-MAR-2014 19:26:39Copyright (c) 1991, 2010, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.11)(PORT=1521))) TNS-12541: TNS:no listenerTNS-12560: TNS:protocol adapter error 《=======监听停止 TNS-00511: No listener Linux Error: 111: Connection refused[oracle@ttdev ~]$ ps -ef | grep smonoracle 3585 3326 0 19:26 pts/1 00:00:00 grep smon 《===没有数据库实例启动 ------此时,在客户端再次执行 tnsping:------C:Usersliyang>tnsping TTORCLTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 10:27:55Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.ora已使用 TNSNAMES 适配器来解析别名尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))TNS-12541: TNS: 无监听程序 <============解析仍然成功,但是报出 TNS-12541 的错误!------以上测试说明了,监听停止之后,tnsping 无法被远端监听接受============= 以下试验四,五开始之前,我们将启动数据库实例和监听------[oracle@ttdev admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.2.0 - Production on 25-MAR-2014 21:02:31Copyright (c) 1991, 2010, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.11)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.2.0 - ProductionStart Date 25-MAR-2014 21:01:31Uptime 0 days 0 hr. 1 min. 0 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.oraListener Log File /home/oracle/app/oracle/diag/tnslsnr/ttdev/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.11)(PORT=1521)))Services Summary...Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 2 handler(s) for this service...Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...The command completed successfully[oracle@ttdev admin]$ ps -ef | grep smonoracle 4148 1 0 21:01 ? 00:00:00 ora_smon_orcloracle 4261 3326 0 21:02 pts/1 00:00:00 grep smon------ 试验四:删除本地的 tnsnames.ora,之后看一下会出现什么情况------C:Usersliyang>tnsping TTORCLTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 10:31:38Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.ora TNS-03505: 无法解析名称 《=====================这次,连解析都无法成功!------注:编辑tnsnames.ora,如果我将TTORCL 修改为 ORCL,则返回同样的结果------C:Usersliyang>tnsping TTORCLTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 10:33:36Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.oraTNS-03505: 无法解析名称------=============试验五:再来测试一个IP地址输入错误的情景修改tnsnames.ora文件,从192.168.56.11 改为一个不存在的192.168.56.12------TTORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521)) 《==更改IP ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )------C:Usersliyang>ping 192.168.56.12正在 Ping 192.168.56.12 具有 32 字节的数据:来自 192.168.56.1 的回复: 无法访问目标主机。 <====ping 显示了该IP不存在C:Usersliyang>tnsping ttorclTNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 26-3月 -2014 11:54:25Copyright (c) 1997, 2010, Oracle. All rights reserved.已使用的参数文件:C:appliyangproduct11.2.0client_2etworkadminsqlnet.ora已使用 TNSNAMES 适配器来解析别名尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))TNS-12535: TNS: 操作超时 《=======结果是等了较长时间报出超时错误------总结: tnsping 用于诊断各种客户端连接问题还是一个非常好的工具。但是我们要清楚的知道,这个工具能做什么(检查客户端TNS配置),什么不能做(检查数据库实例是否启动,监听端口是否在1521上)!从以上试验我们看到,tnsping的解析成功仅仅意味着本地的tnsnames.ora ,IP地址,TNS_ADMIN 变量等配置成功。但是,完全跟目标数据库实例连接没有任何关系!最后,sqlnet 跟数据库也完全是独立的两个问题。不要因为sqlnet连接方面出错,就肯定是数据库的问题。要从客户端自身先找原因。以上是关于oracle在使用tnsping时,老是提醒:TNS-03505: 无法解析名称?的主要内容,如果未能解决你的问题,请参考以下文章 windows怎么开启vnc服务 如何查看linux发行版版本信息 您可能还会对下面的文章感兴趣: 相关文章 浏览器打不开网址提示“ERR_CONNECTION_TIMED_OUT”错误代码的解决方法 如何安装ocx控件 VMware的虚拟机为啥ip地址老是自动变化 vbyone和EDP区别 linux/debian到底怎么重启和关机 苹果平板键盘被弄到上方去了,如何调回正常? 机器学习常用距离度量 如何查看kindle型号