這篇文章主要介紹如何使用jdbc配置連接數據庫(oracle的RAC配置的數據庫)達到負載均衡的情況
我的問題是我需要設置oracle
注:這樣連接可以通過RAC自動平衡負載
Hi Tom
I couldn
and hope you make it available for anyone else looking for this information
My problem was I needed to configure the Oracle
connect to an Oracle Real Application Cluster (RAC) environment
For example
and node
You would need to configure your tnsnames
the following way:
RAC_DB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = node
(ADDRESS = (PROTOCOL = TCP)(HOST = node
(LOAD_BALANCE = yes)
(FAILOVER = on)
)
(CONNECT_DATA =
(SERVICE_NAME = RAC_DB)
(FAILOVER_MODE = (TYPE = SELECT)
(METHOD = BASIC)
(RETRIES =
(DELAY =
)
)
)
Now if you start a SQL*PLUS session
node
connect you to the node
pretty cool to see the first time
To pass this same information to the Oracle
concatenate a shorten version of the tnsnames information above and pass this to
the driver
String userid =
String password =
String tnsnames_info =
String url =
DriverManager
Connection dbConnection = DriverManager
That
then you should see these connections load balance across the two instances
One last note
HTH
and we said
you made it really hard
all could be/should be setup on the listener side!
you have one listener
that would be another option
Reviews
I think we tried that and it didn
Reviewer: Peter Tran from Houston
Hi Tom
I
approach will work if you use the OCI driver
Please send me an example of what you mean or what files I should configure to
test it out
I
Thanks
Followup:
you need to set up mts and a single listener
pmon on each of the rac instances will tell the listener about the load and away
it goes
loaded
ramps
Unknown territory
Reviewer: Peter Tran from Houston
I
frustrate you with my ignorance
I should read to brush up on this information?
I
For example
Why can
Thanks for the quick response
Followup:
in order for a single listener to service many instances
machines
listener cannot
be running on the machine the instance is on
addresses to redirect the client request to
htm
it is just inherit in the architecture
From:http://tw.wingwit.com/Article/program/Oracle/201311/17131.html