ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORA-12545 TNS: Host or Object Does not Exist

ORA-12545 TNS: Host or Object Does not Exist

原创 Linux操作系统 作者:dcswinner 时间:2011-11-28 20:50:58 0 删除 编辑

       上周五下午在客户那正开着会,忽然接到一个电话,是楼下的那个项目经理打来的,说他的客户端连不了oracle数据库了。我问其报什么错误没有,那个项目经理说报 ORA-12545主机或目标不存在的错误。 听到这个错误后,一般是由于链接rac数据库时,客户端没有在其windows的hosts文件里写上数据库服务器的主机名,或者是写了,但是被360杀毒软件注释了,这个问题这两年经常有开发人员问我,然后通过此法解决,因此我也让其将数据库主机名写到hosts文件里。挂了电话继续接着开会,不一会,那个项目经理又打电话过来说,他在hosts文件里添了服务器主机名后,还是报相同的错误,然后我问其应用服务器连数据库有没有问题,他说没有,这样系统还是可以使用,只是他自己连不了,因此我说等会开完会过去帮其看看。

      傍晚来到他的项目组,分析了一下原因,发现确实还存在这个问题,因此就上metalink上查了一下:

Client Connection to RAC Intermittently Fails-ORA-12545 TNS: Host or Object Does not Exist [ID 364855.1]

Applies to:

Oracle Net Services - Version: 9.2.0.8.0 to 11.2.0.3 - Release: 9.2 to 11.2
Information in this document applies to any platform.
Checked for relevance on 30-SEP-2011.

Symptoms

When attempting to connect to a RAC service name, the connection intermittently fails with an ORA-12545 error:  TNS: Host or object doesn't exist.   The expected behavior. is that the connection would be redirected to any of the listener in the cluster where the listener is running on the VIP.  This is normal under RAC Cluster node load balancing. 

However, when the server side listener endpoints are not correctly configured OR the client cannot resolve all forms of the VIP hostname, this error can get thrown.

Changes

This is likely a new installation of RAC cluster.

Cause

Whe LOCAL_LISTENER is not set at all or is not set correctly, PMON can register both the VIP hostname and the physical hostname with the REMOTE_LISTENER.  This is incorrect in RAC but if it does occur, the client can intermittently be routed to a listener endpoint on either of these addresses.  If the client is unable to resolve the physical hostname or even the vip hostname, the connection will fail with ORA-12545.

And important first set is to check the output for :  lsnrctl services

You should not see the physical hostname in the handler information for your RAC instances.   Here's an example of an incorrect lsnrctl services output for a 2-node RAC cluster:

lsnrctl services oracle_rac_listener
Service "oracle.oracle.com" has 2 instance(s).
Instance "orcl1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=myphysicalhost1)(PORT=1521))
"DEDICATED" established:326 refused:0 state:ready
LOCAL SERVER

Instance "orcl2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:394371 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=myphysicalhost2)(PORT=1521))

 

Here's an example of what it ought to look like when LOCAL_LISTENER is configured correctly:

lsnrctl services oracle_rac_listener
Service "oracle.oracle.com" has 2 instance(s).
Instance "orcl1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=myVIP_host1)(PORT=1521))
"DEDICATED" established:326 refused:0 state:ready
LOCAL SERVER

Instance "orcl2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:394371 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=myVIP_host2)(PORT=1521))

 

Solution

Log in with privileges to the instance and issue the following commands so that LOCAL_LISTENER is set correctly:

 

alter system set LOCAL_LISTENER="(address=(protocol=tcp)(port=1521)(host=)) scope=both sid='INSTANCE_NAME1';

Do the same for the 2nd instance where host is set to the and the sid is set to the 2nd instance name.

alter system set LOCAL_LISTENER="(address=(protocol=tcp)(port=1521)(host=)) scope=both sid='INSTANCE_NAME2';


Now the correct address using the VIP hostname will be registered against the listeners in the cluster.

The client should be able to resolve all forms of the VIP host via their /etc/hosts file.  i.e. short name and fully qualified.

这貌似是oracle的一个bug,按照此文档设置local_listener参数后,客户端链接正常,问题解决。

今天下午又有一个大学同学在群里问及此问题,我让其按照此办法设置后,问题也解决了。看来这个问题比较普遍,因此写此日记记录之。

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

请登录后发表评论 登录
全部评论

注册时间:2009-04-03

  • 博文量
    61
  • 访问量
    556427