oracle RAC测试--failover and balance

今天配置好RAC,准备找些资料测试一下。

下文转自:http://space.itpub.net/16628454/viewspace-567384
2009年6月16日,重新测试了failover and balance,推翻了以前的原稿,以下看到的是修订版.

实际上在OCI客户端上的tnsname.ora中的配置,其实可以更简单,简单的不能再简单.

RAC相关信息:
RAC1:10.10.10.1(vip:10.10.10.11) devdb1
RAC2:10.10.10.2(vip:10.10.10.12) devdb2
racdb:devdb
创建的有CRM服务

1、在OCI客户端tnsname中配置如下,仅仅只需要如此添加即可:

RACDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.2)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = devdb)
      (FAILOVER_MODE =
        (TYPE = SELECT)
        (METHOD = BASIC)
        (RETRIES = 180)
        (DELAY = 5)
      )
    )
  )


2、使用SQLPLUS连接:
C:\Documents and Settings\Administrator>sqlplusnam/nam@racdb

SQL*Plus: Release 11.1.0.6.0 - Production on 星期日 3月 15 13:04:11 2009

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


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

SQL> select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
devdb2

SQL>

目前我连接的是devdb2,现在我们验证failover:

登陆到rac2上,shutdown devdb2:

Last login: Fri Feb 27 21:28:08 2009 from 10.10.10.5
rac2-> sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 15 13:07:09 2009

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

再回到OCI客户端的SQLPLUS中,测试:

INSTANCE_NAME
--------------------------------
devdb2

SQL>select instance_name from v$instance;

INSTANCE_NAME
--------------------------------
devdb1

SQL>

实现了无缝FAILOVER。

3、以下测试balance:

分别在rac1和rac2上配置一下参数,以避免ora-12545的错误:
SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.11)(PORT=1521))' SID='devdb1';

System altered.

SQL>

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.12)(PORT=1521))' SID='devdb2';

System altered.

SQL>

在OCI客户端编写BAT脚本,脚本内容如下:
for /L %%G in (1,1,10) do start /b sqlplusnam/nam@racdb
目的,创造10个连接。

验证两台机器目前的连接数:

SQL> select count(*),machine from v$session group by machine;

  COUNT(*) MACHINE
---------- ----------------------------------------------------------------
        30 rac1
      

SQL> select count(*),machine from v$session group by machine;

  COUNT(*) MACHINE
---------- ----------------------------------------------------------------
        29 rac2

运行程序后再次验证:

SQL> select count(*),machine from v$session group by machine;

  COUNT(*) MACHINE
---------- ----------------------------------------------------------------
        30 rac1
         5 WORKGROUP\WWW-CD2CAF03643

SQL>

SQL> /

  COUNT(*) MACHINE
---------- ----------------------------------------------------------------
         5 WORKGROUP\WWW-CD2CAF03643
        29 rac2

SQL>

10个连接每台机器5个,实现了balance的目的。

你可能感兴趣的:(oracle)