应用程序连接oracle rac

时间:2024-08-14 11:37:44

10g rac vip漂移的目的不是让client不加改变的连接过来
而是让client尽快收到一个连接终止的包,然后由client去连接tnsnames中配置的下一个地址。
和没有vip相比, 使用vip可以减少由于db当机而引起的client等待。

oracle rac的vip真正作用不是让应用程序进行透明切换,应用程序还是必须自己配置多个监听ip才行,否则不能切换,配置多个vip,方法如下:在dblink中也要这么配置

1.应用程序连接Oracle rac的URL写法:

应用程序连接oracle rac
 #Oracle(AMS)
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.199)(PORT = ))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.198)
(PORT = ))(LOAD_BALANCE = yes)(FAILOVER = yes)(CONNECT_DATA =(SERVICE_NAME = kobra)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RET
IRES = )(DELAY = ))))
jdbc.username=kms
jdbc.password=kms #Oracle(Addon-KOBRA)
jdbc1.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc1.url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.199)(PORT = ))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.198
)(PORT = ))(LOAD_BALANCE = yes)(FAILOVER = yes)(CONNECT_DATA =(SERVICE_NAME = kobra)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RE
TIRES = )(DELAY = ))))
jdbc1.username=bond
jdbc1.password=bond
应用程序连接oracle rac

备注:如果使用scap ip,可以将以下代码直接替换成scan ip,形式为:jdbc:oracle:thin:@scap ip:1521:kobra

应用程序连接oracle rac
 (DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.199)(PORT = ))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.198)
(PORT = ))(LOAD_BALANCE = yes)(FAILOVER = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = kobra)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RET
IRES = )(DELAY = ))))
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.199)(PORT = ))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.176.198
)(PORT = ))(LOAD_BALANCE = yes)(FAILOVER = yes)(CONNECT_DATA =(SERVICE_NAME = kobra)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RE
TIRES = )(DELAY = ))))
应用程序连接oracle rac

2.客户端tnsnames.ora文件写法如下:

RACDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.7)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.8)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
      (FAILOVER_MODE =
        (TYPE = SELECT)
        (METHOD = BASIC)
        (RETRIES = 180)
        (DELAY = 5)
      )
    )
  )
应用程序连接oracle rac

备注:同样,可以将以下ip地址用sacn ip或域名替来替换

应用程序连接oracle rac
 ractest =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan-ip.localdomain)(PORT = ))
(LOAD_BALANCE= yes)
(FAILOVER= yes)
(CONNECT_DATA = (SERVICE_NAME = kobra)
)
)