Oracle9i, 10g, 11g 負載均衡(load balance)和Fail Over

tolywang發表於2009-05-05

關鍵詞:  load balance (負載均衡) , fail over (透明切換) 

以Oracle10g 為例子,Linux AS4.5 

以下是listener.ora ,  tnsnames.ora ,  spfile 中的幾個配置 。

ecsrac01$cat   listener.ora  
# listener.ora.ecsrac01 Network Configuration File: /u01/product/oracle/network/admin/listener.ora.ecsrac01
# Generated by Oracle configuration tools.

LISTENER_ECSRAC01 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521)(IP = FIRST))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.134.130.177)(PORT = 1521)(IP = FIRST))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )

 

ecsrac01$cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/product/oracle/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ECSDB2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip02)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ecsdb)
      (INSTANCE_NAME = ecsdb2)
    )
  )

ECSDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ecsdb)
      (INSTANCE_NAME = ecsdb1)
    )
  )

ECS =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.134.130.170)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ecsdb)
    )
  )

ECSDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip02)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ecsdb)
     (FAILOVER_MODE =
       (TYPE = SELECT)
       (METHOD = BASIC)
       (RETRIES = 180)
       (DELAY = 5)
     )
    )
  )

LISTENERS_ECSDB =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip02)(PORT = 1521))
  )


LOCAL_ECSDB =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.134.130.177)(PORT = 1521))
  )

 

SQL> show parameter list

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      LOCAL_ECSDB
remote_listener                      string      LISTENERS_ECSDB

 

 

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

客戶端Load Balance,Failover 設定 :

ECSDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip02)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ecsdb)
     (FAILOVER_MODE =
       (TYPE = SELECT)
       (METHOD = BASIC)
       (RETRIES = 180)
       (DELAY = 5)
     )
    )
  )

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

Server 端Load Balance,Failover 設定 :

Server 端的tnsnames.ora 中包含有

LISTENERS_ECSDB =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip01)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecsvip02)(PORT = 1521))
  )

然後remote_listener 設定為tnsnames.ora 中的這個監聽設定即可 。

SQL> show parameter list

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      LOCAL_ECSDB
remote_listener                      string      LISTENERS_ECSDB

 

 

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

相關文章