一、修改客戶端服務(wù)器hosts記錄
192.168.1.240 rac01
192.168.1.241 rac02
-
192.168.1.242 rac01-vip
192.168.1.243 rac02-vip
108.88.3.240 rac01-priv
108.88.3.241 rac02-priv
二、新建一條Tnsname 紀(jì)錄
編輯客戶端:tnsnames.ora 文件,增加如下:
RACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
(FAILOVER_MODE=
(TYPE = session)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
)
三、測試RAC Failover
1、RAC狀態(tài)
[Oracle@rac01 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM1.asm application ONLINE ONLINE rac01
ora....01.lsnr application ONLINE ONLINE rac01
ora.rac01.gsd application ONLINE ONLINE rac01
ora.rac01.ons application ONLINE ONLINE rac01
ora.rac01.vip application ONLINE ONLINE rac01
ora....SM2.asm application ONLINE ONLINE rac02
ora....02.lsnr application ONLINE ONLINE rac02
ora.rac02.gsd application ONLINE ONLINE rac02
ora.rac02.ons application ONLINE ONLINE rac02
ora.rac02.vip application ONLINE ONLINE rac02
ora.racdb.db application ONLINE ONLINE rac01
ora....b1.inst application ONLINE ONLINE rac01
ora....b2.inst application ONLINE ONLINE rac02
[oracle@rac01 ~]$
2、客戶端連接測試
[Oracle@rac01 ~]$ sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Jul 16 21:59:20 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> conn system/Oracle@racdb
Connected.
SQL> select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
racdb1
SQL>
3、關(guān)閉節(jié)點racdb1實例
[Oracle@rac01 ~]$ sqlplus '/ as sysdba';
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Jul 16 22:00:17 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> shutdown abort
Oracle instance shut down.
SQL>
4、在原來客戶端的會話上執(zhí)行連妝測試,
SQL> conn system/Oracle@racdb
Connected.
SQL> select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
racdb1
SQL> /
select instance_name from v$instance
*
ERROR at line 1:
ORA-25408: can not safely replay call
SQL> /
INSTANCE_NAME
--------------------------------
racdb2
SQL>
結(jié)論:在RAC環(huán)境中,同一會話,當(dāng)前會話連接節(jié)點實例故障,可以快速的切替的另一節(jié)中運行,對客戶端的是完全透明的。
本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|