WEB开发网
开发学院数据库Oracle Oracle RAC 客户端连接负载均衡(Load Balance) 阅读

Oracle RAC 客户端连接负载均衡(Load Balance)

 2012-10-11 16:11:30 来源:WEB开发网   
核心提示: 一、客户端的负载均衡客户端的负载均衡主要是通过为tnsnames.ora增加load_balance=yes条目来实现,下面看看oracle(Note:226880.1)的解释The client load balancing feature enables clients to randomize connecti

 一、客户端的负载均衡
客户端的负载均衡主要是通过为tnsnames.ora增加load_balance=yes条目来实现,下面看看oracle(Note:226880.1)的解释
The client load balancing feature enables clients to randomize connection requests among the listeners. Oracle Net progresses through the list of
protocol addresses in a random sequence, balancing the load on the various listeners. Without client load balancing, Oracle Net progresses through the
list of protocol addresses sequentially until one succeeds. This normally is referred to connect-time load balance.
从上面的描述中可以得知,如果未开启load_balance=yes时,Oracle Net会根据地址列表按顺序来选择一个进行连接,直到连接成功为止。
如果第一个host主机连接失败,在有多个地址的情形下,接下来选择第二个地址连接,依此类推,直到连接成功为止。
当开启了load_balance=yes时,则Oracle Net会从多个地址中随机地选择一个地址进行连接,直到连接成功为止。
注意,此连接方式仅根据地址列表随机选择,并不考虑到各个实例上当前真正连接数量的多少,也即是没有考虑各个节点真实的连接负载情况。

二、服务器与客户端的配置情况

1、服务器端监听器配置
oracle@bo2dbp:~> more $ORACLE_HOME/network/admin/listener.ora  --#节点bo2dbp上的listener
# listener.ora.bo2dbp Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbp
# Generated by Oracle configuration tools.

LISTENER_NEW_BO2DBP =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbp-vip.2gotrade.com)(PORT = 1314)(IP = FIRST))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.51)(PORT = 1314)(IP = FIRST))
    )
  )
...........................--#其余部分省略,注意此处的配置是使用了1314的非缺省监听器端口号   
 
oracle@bo2dbs:/u01/oracle/db/network/admin> more listener.ora  --#节点bo2dbs上的listener
# listener.ora.bo2dbs Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbs
# Generated by Oracle configuration tools.

LISTENER_NEW_BO2DBS =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbs-vip.2gotrade.com)(PORT = 1314)(IP = FIRST))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.52)(PORT = 1314)(IP = FIRST))
    )
  )
...............

2、参数配置
-->instrance ora10g1上的参数配置
SQL> show parameter instance_na

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      ora10g1

SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      local_lsnr_ora10g1
remote_listener                      string      remote_lsnr_ora10g

-->instrance ora10g2上的参数配置
SQL> show parameter instance_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      ora10g2

SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      local_lsnr_ora10g2
remote_listener                      string      remote_lsnr_ora10g

-->instrance ora10g2上的监听信息
SQL> ho ps -ef | grep lsnr
oracle   17372     1  0 11:00 ?        00:00:00 /u01/oracle/db/bin/tnslsnr LISTENER_NEW_BO2DBS -inherit
oracle   17502 24301  0 12:10 pts/0    00:00:00 /bin/bash -c ps -ef | grep lsnr
oracle   17504 17502  0 12:10 pts/0    00:00:00 grep lsnr

SQL> ho lsnrctl status LISTENER_NEW_BO2DBS
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.62)(PORT=1314)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.52)(PORT=1314)))
Services Summary...
Service "ora10g" has 2 instance(s).
  Instance "ora10g1", status READY, has 1 handler(s) for this service...
  Instance "ora10g2", status READY, has 2 handler(s) for this service...
..........
  
-->由于只是测试基于客户端的load balance,因此移出remote_listener参数
SQL> alter system reset remote_listener scope=both sid='*';
alter system reset remote_listener scope=both sid='*'
*
ERROR at line 1:
ORA-32009: cannot reset the memory value for instance * from instance ora10g2

SQL> alter system reset remote_listener scope=spfile sid='*';

System altered.

SQL> ho srvctl stop database -d ora10g  -->关闭数据库ora10g

SQL> ho srvctl start database -d ora10g  -->启动数据库ora10g使得刚刚修改的remote_listener生效

SQL> ho lsnrctl status LISTENER_NEW_BO2DBS  -->此时可以看到只有ora10g2注册到监听器

Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.62)(PORT=1314)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.52)(PORT=1314)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "ora10g" has 1 instance(s).
  Instance "ora10g2", status READY, has 1 handler(s) for this service...
..........  

oracle@bo2dbp:~> lsnrctl status LISTENER_NEW_BO2DBP  #同样在节点bo2dbp也只有ora10g1注册到监听器

Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.61)(PORT=1314)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.51)(PORT=1314)))
Services Summary...
Service "ora10g" has 1 instance(s).
  Instance "ora10g1", status READY, has 1 handler(s) for this service...
.........

3、客户端配置
SZDB:~ # ifconfig eth1 | grep "inet addr"|cut -d " " -f12|cut -d : -f2  #客户端主机的ip
192.168.7.2

SZDB:~ # su - oracle
oracle@SZDB:~> cat /etc/hosts     --#客户端主机添加了RAC上的两个虚拟节点的ip信息
192.168.7.61   bo2dbp-vip.2gotrade.com    bo2dbp-vip
192.168.7.62   bo2dbs-vip.2gotrade.com    bo2dbs-vip

oracle@SZDB:~> tail -12 $ORACLE_HOME/network/admin/tnsnames.ora

ORA10G =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbp-vip.2gotrade.com)(PORT = 1314))
    (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbs-vip.2gotrade.com)(PORT = 1314))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora10g)
    )
  )

1 2  下一页

Tags:Oracle RAC 客户端

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接