配置tnsnames.ora遇到的几个问题总结

本文总结了在配置tnsnames.ora文件过程中遇到的问题及解决办法,包括监听程序未启动、目标主机不存在、服务名不匹配等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

配置tnsnames.ora遇到的几个问题总结
今天打算在本地配置下tnsnames.ora,以便方便的访问虚拟机中的数据库,这样就可以不需要用secure crt进入到linux主机再进入数据库了。其中遇到了几个问题,总结如下:
在windows cmd中连接目标数据库的时候遇到
ORA-12541: TNS: 无监听程序
ERROR:
[oracle@zeng ~]$ oerr ora 12541
12541, 00000, "TNS:no listener"
// *Cause: The connection request could not be completed because the listener
// is not running.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry with
// the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to
// go by way of an Interchange). Start the listener on the remote machine.
查看监听程序的状态
[oracle@zeng ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-FEB-2012 12:16:09
Copyright (c) 1991, 2009, 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@zeng ~]$ lsnrctl start 
总结:原因是目标主机中数据库的监听程序没有启动。
ORA-12545: 因目标主机或对象不存在, 连接失败
[oracle@zeng ~]$ oerr ora 12545
12545, 00000, "Connect failed because target host or object does not exist"
// *Cause: The address specified is not valid, or the program being 
// connected to does not exist.
// *Action: Ensure the ADDRESS parameters have been entered correctly; the
// most likely incorrect parameter is the node name.  Ensure that the 
// executable for the server exists (perhaps "oracle" is missing.)
// If the protocol is TCP/IP, edit the TNSNAMES.ORA file to change the
// host name to a numeric IP address and try again.
原tnsnames,ora中的内容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =zeng)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl.zeng.com)
    )
  )
修改以后的tnsnames.ora中的内容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.101)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl.zeng.com)
    )
  )
总结:原因是目标主机不存在,或者DNS无法解析主机名,尝试换成主机的IP地址。
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
可以使用下面的命令具体的查看错误信息,不过上面的提示已经很清楚了。
[oracle@zeng ~]$ oerr ora 12514
修改tnsmame.ora中的内容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.101)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl)
    )
  )
即SERVICE_NAME = oracl.zeng.com修改成SERVICE_NAME = oracl
总结:因为数据库服务名默认是和全局数据库服务名一致的,我把数据库全局名当数据库服务名用了。我要连接的数据库中的数据库服务名与全局数据库名没有配置成一致。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26110315/viewspace-717135/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26110315/viewspace-717135/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值