oracle10G RAC环境ora-12545 错误

问题示例:
在pc 机用sqlplus 连 总有 25% 的 连接失败, 报错:   TNS-12545: Connect failed because target host or object does not exist

下面是一些相关配置:

listener.ora
----------------------------------------------------------------------------------------------------------
LISTENER_CNBEIORAPRD01 =
   (DESCRIPTION_LIST =
(DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 3.36.234.52)(PORT = 1521))
   (ADDRESS = (PROTOCOL = TCP)(HOST = 3.36.234.51)(PORT = 1521))
)
   )

SID_LIST_LISTENER_CNBEIORAPRD01 =
   (SID_LIST =
(SID_DESC =
   (SID_NAME = PLSExtProc)
   (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
   (PROGRAM = extproc)
)
   )


SQL> show parameter list;

NAME                               TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string
remote_listener                   string    LISTENERS_JSST


more tnsnames.ora
.....
LISTENERS_JSST =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =3.36.234.52)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =3.36.234.50)(PORT = 1521))
)
.....

more /etc/hosts
127.0.0.1    localhost.localdomain
3.36.234.51     cnbeioraprd01
3.36.234.53     cnbeiorastg01
3.36.234.52     cnbeioraprd01-vip
3.36.234.50     cnbeiorastg01-vip
192.168.1.1     cnbeioraprd01-priv
192.168.1.2     cnbeiorastg01-priv

原因:
当有监听器的LOAD_BALANCE时 ,每当client建立一个链接的时候listener是需要给client一个地址去连接的,但是它给的并不是ip,而是给的hostname,所以客户端再用这个hostname去链接的时候自然就要报"ora-12545 因目标主机或对象不存在,连接失败"当配置LB后,监听接收到请求后,假如要被重定向到remote listener,此时发给客户机的链接信息是remote listener的hostname,而不是IP

metalink:[ID 553328.1]

Problem : Client connections to RAC database servers fail with ORA-12545 / TNS-12545

Cause: One of the hostname (which corresponds to public IP or VIP) is not reachable from this client machine.
When the server side load balancing is enabled in the RAC setup, the listener will redirect the connection to the least loaded node.While doing so, the server sends the packet NSPTRD containing the hostname of the corresponding machine.

Oracle在文档Note:364855.1:RAC Connection Redirected To Wrong Host/IP ORA-12545中进行了相信的描述。
并给出了解决方法:修改数据库中的初始化参数LOCAL_LISTENER:

SQL> CONN SYS@TESTRAC1 AS SYSDBA输入口令: ****已连接。
SQL> ALTER SYSTEM
2 SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))'
3 SID = 'testrac1';
系统已更改。
SQL> CONN SYS@TESTRAC2 AS SYSDBA输入口令: ****已连接。
SQL> ALTER SYSTEM
2 SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))'
3 SID = 'testrac2';
系统已更改。


-----------------------
+++  如果效果不好 ,还可以

2.在服务器端racdb1,racdb2上分别编辑tnsnames.ora和listener.ora文件,将两个文件中的host主机名字均修改为具体的VIP地址
如将下面部分
LISTENERS_ORCL =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = racdb1-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = racdb2-vip)(PORT = 1521))
  )
改为:
LISTENERS_ORCL =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.12.21)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.12.22)(PORT = 1521))
  )

3.在racdb1节点的tnsnames.ora增加如下内容
local_listener_rac =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.12.21)(PORT = 1521))
  )

4.在racdb2节点的tnsnames.ora增加如下内容
local_listener_rac =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.12.22)(PORT = 1521))
  )

4.使用 sqlplus / as sysdba 登陆数据库修改local_listener参数

alter system set local_listener='local_listener_rac' scope=both;

5.重启两节点的实例和监听
sys@orcl> shutdown immediate;
sys@orcl> startup;

$ lsnrctl stop
$ lsnrctl start


你可能感兴趣的:(oracle,sql,SQL Server)