nginx TCP 负载均衡在oracle 10g负载均衡实践

来源:互联网 发布:淘宝发布定制产品 编辑:程序博客网 时间:2024/05/17 08:45

oracle10g不支持SCAN,尝试了jdbc的多连接方式:

(1)thin模式,这个模式是用本地的连接串来实现数据库连接;

(2)oci模式,这个模式是依赖与tnsname,所以要不得安装client要不dbsoft

因为操作系统所限,因为10g 只能安装在rhel4\5之上(只针对linux上来说)。

而且尝试各种写法在11g的客户端上都有问题。

所以就想到了能不能用代理的方式来实现VIP的负载均衡。

而,nginx0.9版本之后支持了TCP\UDP三层的负载均衡功能,之前只是在http、mail上做的七层负载,尝试了下,结果令人满意。


1.软件安装

./configure --prefix=/usr/local/nginx --with-stream --without-http_rewrite_module

--without-http_rewrite_module 此项目用于url重定向,这里不需要,因为是三层的数据转换,所以不用这个模块;


make && make install

2.配置

worker_processes auto;error_log /usr/local/nginx/logs/error.log info;events {    worker_connections  1024;}stream {    upstream orarac {        server 192.168.137.130:1521;        server 192.168.137.131:1521;    }    server {        listen 1522 so_keepalive=on;        proxy_pass orarac;    }}

so_keepalive,会话保持,这个得有,要不然在数据库连接的时候就会一个查询在A点另一个飘了,


[oracle@rhel65 ~]$ sqlplus scott/tiger@127.0.0.1:1522/iwhmSQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 2 23:12:38 2016Copyright (c) 1982, 2014, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Data Mining and Real Application Testing optionsSQL> show parameters;ORA-03113: end-of-file on communication channelProcess ID: 11402Session ID: 19 Serial number: 37

3.在数据库上查询会话情况

SQL>  select inst_id,username from gv$session where username is not null;   INST_ID USERNAME---------- ------------------------------ 1 BMSQL 1 BMSQL 1 SYS 1 SYS 1 BMSQL 1 BMSQL 1 BMSQL 1 SYS 2 SYS 2 BMSQL 2 BMSQL 2 SYS 2 SYS 2 BMSQL14 rows selected.

基本上可以保持均衡



0 0
原创粉丝点击