Oracle 10g RAC客戶端配置監聽

woshishui11211發表於2015-03-16

RAC中,負載均衡分為兩種,一種是基於客戶端連線的,另外一種是基於伺服器端的。

 

現在主流都是基於服務端的,伺服器端的負載均衡可以根據RAC中各節點的負荷及連線數情況,而判定將新的客戶端連線分配到負荷最小的節點上去

 

 

服務端監聽在建立例項的時候自動建好

 

 

$ lsnrctl status

 

LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.1.0 - Production on 07-MAY-2014 13:37:53

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER_RAC1

Version                   TNSLSNR for IBM/AIX RISC System/6000: Version 10.2.0.1.0 - Production

Start Date                07-MAY-2014 12:07:52

Uptime                    0 days 1 hr. 30 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      ON

Listener Parameter File   /u01/oracle/product/10.2/db_1/network/admin/listener.ora

Listener Log File         /u01/oracle/product/10.2/db_1/network/log/listener_rac1.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.191)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.180)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...

Service "+ASM_XPT" has 1 instance(s).

  Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...

Service "orcl" has 2 instance(s).

  Instance "orcl1", status READY, has 2 handler(s) for this service...

  Instance "orcl2", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 2 instance(s).

  Instance "orcl1", status READY, has 1 handler(s) for this service...

  Instance "orcl2", status READY, has 1 handler(s) for this service...

Service "orcl_XPT" has 2 instance(s).

  Instance "orcl1", status READY, has 2 handler(s) for this service...

  Instance "orcl2", status READY, has 1 handler(s) for this service...

The command completed successfully

 

 

SQL> show parameter remote_listener;

 

NAME                                 TYPE

------------------------------------ ---------------------------------

VALUE

------------------------------

remote_listener                      string

LISTENERS_ORCL

 

 

 

客戶端配置:

1)         先手動按常規建立本地服務

Netca

 

clip_image002clip_image004clip_image006

 

輸入第一個節點的VIP地址

clip_image008

 

clip_image010clip_image012clip_image014clip_image016clip_image018

 

 

2)         手動修改tnsnames.ora檔案,將第2個節點的VIP 192.168.0.192也新增進去

D:\product\10.2.0\client_1\NETWORK\ADMIN

tnsnames.ora

修改前:

ORCL =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.191)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orcl)

    )

  )

 

修改後:

ORCL =

  (DESCRIPTION =

    (FAILOVER = on)

    (LOAD_BALANCE = yes)

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.191)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.192)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orcl)

      (FAILOVER_MODE=

          (TYPE = select)

          (METHOD = basic)

          (RETRIES = 180)

          (DELAY = 5)

      )

    )

  )

3)         測試連線

clip_image020

 

客戶端會根據服務端的壓力,新連線自動連線到壓力小的節點上,實現負載均衡

clip_image022

 

 

4)         模擬主節點當機

將主節點執行halt –q關機

clip_image023

 

過幾分鐘

clip_image025

 

 

clip_image026

 

 

在客戶端用sqlplus連線伺服器資料庫可能會出現如下錯誤:

ERROR:

ORA-12545: 因目標主機或物件不存在,連線失敗

 

解決ORA-12545連線失敗問題

配置客戶端的Hosts檔案

通過在客戶端的Hosts檔案中加入對兩個服務名的主機名字解析可以解決ORA-12545問題。

192.168.0.191 rac1

192.168.0.192 rac2

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26217983/viewspace-1461473/,如需轉載,請註明出處,否則將追究法律責任。

相關文章