JDBC 如何配置RAC 的Load Balance ?

tolywang發表於2009-05-21

How to Implement Load Balancing With RAC Configured System Using JDBC

: 247135.1

 

PURPOSE
-------

This document discusses how to implement load balancing from a JDBC application
that connects to a RAC configured system.


SCOPE & APPLICATION
-------------------

This material is intended for developers or analysts.


How to Implement Load Balancing With RAC Configured System Using JDBC
---------------------------------------------------------------------
Here are the steps to follow in configuring load balancing and connecting
with a JDBC program:

1.  Verify that from the same system that you are running your JDBC program that
load balancing is working from sqlplus.

If you do not have sqlplus on the same system that you will be running your
JDBC program from, download the "Instant Client" that contains sqlplus from :



Here are some notes that will help you get the setup working:

Configuration of Load Balancing and Transparent Application Failover
Understanding and Troubleshooting Instance Load Balancing
Client Load Balancing and Failover Using Description and Address_List

The following note provides a script. for automating the testing of load
balancing from sqlplus (just ignore the oc4j references):

How to setup Fast Connection Failover within OAS 10.1.3 oc4j instances

Use your connect string if you use this script.

2. Now modify the connection string (host:port:sid) in your JDBC program
with the full name-value pair syntax as used in step (1) ...


url="jdbc:oracle:thin:@(DESCRIPTION=
     (LOAD_BALANCE=on)
        (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521))
        (ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=service_name)))"
or

url="jdbc:oracle:thin:@(DESCRIPTION=
        (ADDRESS=(PROTOCOL=TCP)(HOST=cluster_alias) (PORT=1521))
        (CONNECT_DATA=(SERVICE_NAME=service_name)))"


conn = DriverManager.getConnection(url, user_name, password);

You can use the TestFailover program in the following note:

How to Implement Connect Failover Using JDBC Thin

with your connect string as a starting example.

 

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

相關文章