这篇文章主要介绍如何使用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 SQLPLUS session then you should see a connection on thenode instance If you start another SQLPLUS 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
lishixinzhi/Article/program/Oracle/201311/17131
本文我们主要介绍了MySQL数据库集群实现负载均衡的安装配置工作,接下来我们就让我们一起来了解一下这部分内容。
MySQL数据库集群关系如下图:
ndbd:数据库节点,物理数据实际存放位置。
mysqld:MySQL服务器节点。
ndbd_mgmd:管理节点。管理/查看各库节点和服务器节点的状态。程序直接访问的是这台机器的IP。默认端口仍是3306。
1在ndb_mgmd、mysqld、Node A、Node B上安装MySQL50
安装目录:/usr/local/mysql
2配置 Node A、Node B、mysqld:
# cp /usr/local/mysql/support-files/my-mediumcnf /etc/mycnf # vi /etc/mycnf 在文件尾加入 # mycnf # example additions to mycnf for MySQL Cluster # (valid in MySQL 50) # enable ndbcluster storage engine, and provide connectstring for # management Server host (default port is 1186) [mysqld] ndbcluster ndb-connectstring=1921685630 # provide connectstring for management Server host (default port: 1186) [ndbd] connect-string=1921685630 # provide connectstring for management Server host (default port: 1186) [ndb_mgm] connect-string=1921685630 # provide location of cluster configuration file [ndb_mgmd] config-file=/var/lib/mysql-cluster
在Node A、Node B上创建日志文件夹
随着网站、应用访问量的增加,一台服务器租用已经不能满足应用的需求,而需要多台服务器集群,这时就会用到负载均衡,那么负载均衡优点有那些呢,壹基比小喻来说说
负载均衡设备优势
• 负载均衡优化了访问请求在服务器组之间的分配,消除了服务器之间的负载不平衡,从而提高了系统的反应速度与总体性能;
• 负载均衡可以对服务器的运行状况进行监控,及时发现运行异常的服务器,并将访问请求转移到其它可以正常工作的服务器上,从而提高服务器组的可靠性采用了负均衡器器以后,可以根据业务量的发展情况灵活增加服务器,系统的扩展能力得到提高,同时简化了管理。
负载均衡器有多种多样的形式,除了作为独立意义上的负载均衡器外,有些负载均衡器集成在交换设备中,置于服务器与Internet链接之间,有些则以两块网络适配器将这一功能集成到PC中,一块连接到Internet上,一块连接到后端服务器群的内部网络上。
一般而言,硬件负载均衡在功能、性能上优于软件方式,不过成本昂贵。当Web服务器为图像服务、SSL(安全套接层)会话或数据库事务而进行优化时,负载均衡器可以体现特别的价值。
当需要进行服务器升级或系统维护时,保证稳定的服务器退出服务以避免服务中断。当选定某台服务器要退出服务后,将不会将任何新的用户分配到该服务器。但是,它可以要该服务器完成对当前用户的服务。从而保证了无中断的优质服务,并且简化了服务器群的管理。
智能的服务器服务恢复
将重新启动的服务器应用到服务中时,避免新服务器因突然出现的流量冲击导致系统故障是非常重要的。所以,在将新服务器引入服务器群时,将逐渐地增加分配到该服务器的流量,直至达到其完全的处理能力。从而不仅保证用户在服务器退出服务时,同时还保证服务器在启动期间以及应用程序开始时,均能获得不间断服务。
以上就是关于关于JDBC客户端如何连接ORACLE数据库RAC的负载均衡全部的内容,包括:关于JDBC客户端如何连接ORACLE数据库RAC的负载均衡、对于实现mysql数据库集群负载均衡和高可使用 哪些措施具有实际意义、负载均衡服务器有什么优缺点等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)