客户端连接RAC&TNS-12545

今天一个同事说她自己连不上库,报:TNS-12545: 因目标主机或对象不存在, 连接失败
而周围的同事都可以,很明显是她自己的配置出了问题。

E:\sftp>tnsping RACDB

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 22-7月 -

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:
D:\ORACLE\Liangwei\product\11.2.0\dbhome_1\network\admin\sqlnet.ora

已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521))) (LOAD_BALANCE = yes) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = racdb)))
TNS-12545: 因目标主机或对象不存在, 连接失败

客户端连接rac有两个文件要配置hoststnsname.ora,一般配置好这两个文件连rac应该没什么问题。
先后检查了这两个文件,发现hosts中配置RAC 主机名与IP映射的地方被杀毒软件给自动注释掉了。
放开后成功连接数据库。

 

 

简单介绍Oracle客户端连接RAC需要配置的两个文件
一、.配置hosts

Windows中hosts文件位置:C:\Windows\System32\drivers\etc\hosts
Linux/AIX中hosts文件位置:/etc/hosts

在hosts文件中添加:

# Virtual IP address
192.168.1.15  RAC01-vip
192.168.1.16  RAC02-vip
# Public Network
192.168.1.11   RAC01  
192.168.1.12   RAC02

二、.配置客户端tnsname.ora
tnsname.ora位于$ORACLE_HOME/network/admin
RACDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = RAC01-vip)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = RAC02-vip)(PORT = 1521))
    )
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RACDB)
    )
  )

三.测试
sqlplus scott/tiger@RACDB

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 7月 22 14:33:07 2011
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Data Mining and Real Application Te

SQL> select instance_name from gv$instance;

INSTANCE_NAME
----------------
rac02
rac01

你可能感兴趣的:(客户端连接RAC&TNS-12545)