知识大全 关于JDBC客户端如何连接ORACLE数据库RAC的负载均衡
Posted 数据库
篇首语:没关系,天空越黑,星星越亮。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 关于JDBC客户端如何连接ORACLE数据库RAC的负载均衡相关的知识,希望对你有一定的参考价值。
关于JDBC客户端如何连接ORACLE数据库RAC的负载均衡 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
这篇文章主要介绍如何使用jdbc配置连接数据库(oracle的RAC配置的数据库)达到负载均衡的情况 该例子是以 个NODE的情况说明 希望对大家有所帮助
我的问题是我需要设置oracle x的thin客户端连接到oracle的RAC环境上
注:这样连接可以通过RAC自动平衡负载
原文如下:
Hi Tom
I couldn t find this information easily on the net So I m submitting it hereand hope you make it available for anyone else looking for this information
My problem was I needed to configure the Oracle x thin driver (type IV) toconnect to an Oracle Real Application Cluster (RAC) environment
For example assuming you have a database called RAC_DB with o nodes node and node
You would need to configure your tnsnames ora with the following information inthe following way:
RAC_DB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = node )(PORT = )) (ADDRESS = (PROTOCOL = TCP)(HOST = node )(PORT = )) (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 then you should see a connection on thenode instance If you start another SQL*PLUS session then Oracle shouldconnect you to the node instance (automatic load balancing) It s actuallypretty cool to see the first time
To pass this same information to the Oracle s JDBC thin driver you essentiallyconcatenate a shorten version of the tnsnames information above and pass this tothe driver
String userid = scott ; String password = tiger ;
String tnsnames_info = (DESCRIPTION=(ADDRESS_LIST= + (ADDRESS=(PROTOCOL=TCP)(HOST=node )(PORT= )) + (ADDRESS=(PROTOCOL=TCP)(HOST=node )(PORT= )) + (LOAD_BALANCE=yes)(FAILOVER=on)) + (CONNECT_DATA=(SERVICE_NAME=rac_db))) ;
String url = jdbc:oracle:thin:@ + tnsnames_info;
DriverManager registerDriver(new oracle jdbc OracleDriver()); Connection dbConnection = DriverManager getConnection(url userid password);
That s it If your application creates multiple connection to the database then you should see these connections load balance across the o instances
One last note Oracle only supports connection to a RAC configuration with the i drivers so you should try to get the latest Oracle JDBC thin driver
HTH Peter
and we said
you made it really hard you just needed the service! the load balancing andall could be/should be setup on the listener side!
you have one listener both databases register with it as a service
that would be another option
Reviews
I think we tried that and it didn t work September Reviewer: Peter Tran from Houston TX USA
Hi Tom
I m pretty sure we tried that but it didn t work with the thin driver Thatapproach will work if you use the OCI driver but not with the thin driver
Please send me an example of what you mean or what files I should configure totest it out
I m always opened to easier options
Thanks Peter
Followup:you need to set up mts and a single listener thats it
pmon on each of the rac instances will tell the listener about the load and awayit goes you might not see the round robin right off (both are not yetloaded ) so it ll be an unbalanced load balance initially but as the systemramps it ll balance out
Unknown territory September Reviewer: Peter Tran from Houston TX USA
I m sorry but I really lost you with that last remendation Rather thanfrustrate you with my ignorance can you remend the Oracle documentation thatI should read to brush up on this information?
I ll read this first and e back with questions if I m still lost
For example I don t understand why you want me to setup the database as MTS Why can t I use dedicated server mode?
Thanks for the quick response
Peter
Followup:in order for a single listener to service many instances on differentmachines the listener must be servicing shared server connections thelistener cannot fork/exec a dedicated server since the listener may well notbe running on the machine the instance is on it needs to know dispatcheraddresses to redirect the client request to
cha138/Article/program/Oracle/201311/17131
相关参考
知识大全 连接oracle的总结(关于tnsname和监听)
该文是我连接oracle的总结特别适合于程序开发人员与oracle菜鸟 如何配置才能使客户端连到数据库要使一个客户端机器能连接oracle数据库需要在客户端机器上安装oracle
Oracle数据库关于连接池一 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 到目前为目JDBC
通过JDBC连接oracle数据库 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!Java数据库连接
JDBC连接RAC的配置源代码剖析 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! <JDB
通过JDBC连接oracle数据库的技巧 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! Java
如何配置才能使客户端连到数据库 要使一个客户端机器能连接oracle数据库需要在客户端机器上安装oracle的客户端软件唯一的例外就是java连接数据库的时候可以用jdbcthin模式不用装or
在专用连接方式中每一个连接到数据库服务器的客户端请求服务器会和客户端之间建立起连接这个连接用于专门处理该客户端的所有请求直到用户主动断开连接或网络出现中断在连接处于空闲时后台进程PMON会每隔一段时间
Oracle/i/i数据库(thin模式)ClassforName(oraclejdbcdriverOracleDriver)newInstance();Stringurl=jdbc:oracle
Oracle数据库关于连接池二 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! *大连接数为止在返
常用数据库JDBC连接写法大全 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! MySQL()mm