今天重新測(cè)試了RAC的failover和balance,以前由于知識(shí)的匱乏,,一直沒有實(shí)現(xiàn),,今天測(cè)試一下。測(cè)試思路,,分別使用真實(shí)IP和VIP來進(jìn)行測(cè)試,。結(jié)果發(fā)現(xiàn)兩個(gè)IP都可以實(shí)現(xiàn)這兩種特性。
RAC相關(guān)信息:
RAC1:10.10.10.1(vip:10.10.10.11) devdb1
RAC2:10.10.10.2(vip:10.10.10.12) devdb2
racdb:devdb
創(chuàng)建的有CRM服務(wù)
1,、在OCI客戶端tnsname中配置如下,,首先用vip進(jìn)行測(cè)試。
RACDB2=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.12)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
(INSTANCE_NAME = racdb2)
)
)
RACDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = devdb1)
(INSTANCE_NAME = devdb1)
)
)
LISTENERS_RACDB =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.11)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.12)(PORT = 1521))
)
RACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.11)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.12)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = devdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
2,、配置完成,,在OCI客戶端做以下測(cè)試:
C:\Documents and Settings\Administrator>tnsping racdb1
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 15-3月 -
2009 13:02:11
Copyright (c) 1997, 2007, Oracle. All rights reserved.
已使用的參數(shù)文件:
e:\oracle\product\11.1.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10
.11)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = devdb1)
(INSTANCE_NAME = devdb1)))
OK (10 毫秒)
C:\Documents and Settings\Administrator>tnsping racdb2
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 15-3月 -
2009 13:02:12
Copyright (c) 1997, 2007, Oracle. All rights reserved.
已使用的參數(shù)文件:
e:\oracle\product\11.1.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10
.12)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) (
INSTANCE_NAME = racdb2)))
OK (0 毫秒)
C:\Documents and Settings\Administrator>
可以看出,都是通的,。
3.使用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,,現(xiàn)在我們驗(yàn)證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中,,測(cè)試:
INSTANCE_NAME
--------------------------------
devdb2
SQL>select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
devdb1
SQL>
實(shí)現(xiàn)了無縫FAILOVER,。
4、以下測(cè)試balance:
分別在rac1和rac2上配置一下參數(shù),,以避免ora-12545的錯(cuò)誤:
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客戶端編寫B(tài)AT腳本,,腳本內(nèi)容如下:
for /L %%G in (1,1,10) do start /b sqlplusnam/nam@racdb
目的,創(chuàng)造10個(gè)連接。
驗(yàn)證兩臺(tái)機(jī)器目前的連接數(shù):
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
運(yùn)行程序后再次驗(yàn)證:
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個(gè)連接每臺(tái)機(jī)器5個(gè),,實(shí)現(xiàn)了balance的目的,。
5、再次測(cè)試,,使用實(shí)際IP地址測(cè)試,,將OCI客戶端的TNSNAME里VIP全部改為實(shí)際IP,并修改RAC1和RAC2的local_listener地址
SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.1)(PORT=1521))' SID='devdb1';
System altered.
SQL>
SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.2)(PORT=1521))' SID='devdb2';
System altered.
SQL>
6,、使用tnsping測(cè)試連通性:
C:\Documents and Settings\Administrator>tnsping racdb
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 15-3月 -
2009 14:44:02
Copyright (c) 1997, 2007, Oracle. All rights reserved.
已使用的參數(shù)文件:
e:\oracle\product\11.1.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (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))))
OK (5330 毫秒)
C:\Documents and Settings\Administrator>tnsping racdb1
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 15-3月 -
2009 14:44:10
Copyright (c) 1997, 2007, Oracle. All rights reserved.
已使用的參數(shù)文件:
e:\oracle\product\11.1.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10
.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = devdb1) (
INSTANCE_NAME = devdb1)))
OK (0 毫秒)
C:\Documents and Settings\Administrator>tnsping racdb2
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 15-3月 -
2009 14:44:11
Copyright (c) 1997, 2007, Oracle. All rights reserved.
已使用的參數(shù)文件:
e:\oracle\product\11.1.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10
.2)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) (I
NSTANCE_NAME = racdb2)))
OK (0 毫秒)
C:\Documents and Settings\Administrator>
7,、測(cè)試failover:
C:\Documents and Settings\Administrator>sqlplusnam/nam@racdb
SQL*Plus: Release 11.1.0.6.0 - Production on 星期日 3月 15 14:45:09 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>
登陸RAC2,shutdown abort:
......
SQLPLUS測(cè)試:
devdb2
SQL> /
INSTANCE_NAME
--------------------------------
devdb1
SQL>
實(shí)現(xiàn)無縫切換,。
8,、測(cè)試實(shí)際地址的balance,,方法同上:
SQL> select count(*),machine from v$session group by machine;
COUNT(*) MACHINE
---------- ----------------------------------------------------------------
32 rac1
5 WORKGROUP\WWW-CD2CAF03643
SQL>
SQL> select count(*),machine from v$session group by machine;
COUNT(*) MACHINE
---------- ----------------------------------------------------------------
5 WORKGROUP\WWW-CD2CAF03643
31 rac2
SQL>
實(shí)現(xiàn)balance,。