ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RAC负载均衡的简单测试(一)

RAC负载均衡的简单测试(一)

原创 Linux操作系统 作者:yangtingkun 时间:2007-04-11 00:00:00 0 删除 编辑

Rac环境安装完成之后,打算简单测试一下Oracle RAC的负载均衡功能。


配置负载均衡,需要在客户端的tnsnames.ora中进行配置。

TESTRAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testrac)
)
)

设置了LOAD_BALANCE = yes之后,使用TESTRAC服务名连接数据库时就启动了负载均衡功能。

登陆RAC实例,检查两个实例上的会话连接情况:

SQL> SELECT INST_ID, COUNT(*) FROM GV$SESSION GROUP BY INST_ID;

INST_ID COUNT(*)
---------- ----------
1 31
2 31

下面在客户端连接RAC实例,并检查当前连接的是哪个实例:

SQL> CONN NDMAIN@TESTRAC输入口令: ******已连接。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> CONN NDMAIN@TESTRAC输入口令: ******已连接。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

由于两个实例上会话数量相当,所以Oracle在分配连接时,分配给每个实例的概率基本相同。

这是会话连接两次的情况,下面看看当多个会话连接时,Oracle是如何分配的。

SQL> DISC Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
断开

首先断开刚才连接的会话,然后启动4个新的连接,并检查这些连接分布到哪些实例上:

E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3 22 19:15:26 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C)
版权所有 1985-2000 Microsoft Corp.

E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3 22 19:15:46 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C)
版权所有 1985-2000 Microsoft Corp.

E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3 22 19:16:02 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C)
版权所有 1985-2000 Microsoft Corp.

E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3 22 19:16:16 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

可以看到,由于两个实例负载相当,Oracle基本上是按照50%的概率给每个实例分配新的连接。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-69236/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1955
  • 访问量
    10488050