DATA GUARD物理備庫的SWITCHOVER切換

suifeng2316發表於2012-02-15

在進行DATA GUARD的物理備庫切換前需要注意:

1,確認主庫和從庫間網路連線通暢;

2,確認沒有活動的會話連線在資料庫中;

3,PRIMARY資料庫處於開啟的狀態,STANDBY資料庫處於MOUNT狀態;

4,確保STANDBY資料庫處於ARCHIVELOG模式;

5,如果設定了REDO應用的延遲,那麼將這個設定去掉;

6,檢查主備庫初始化引數是否正確

本次測試實驗引數如下:

Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod

備庫node2的引數

db_unique_name=node2

log_archive_config='dg_config=(node1,node2)'

*.log_archive_dest_1='location=g:\database\oradata\node2\arch

valid_for=(all_logfiles,all_roles)

db_unique_name=node2'

log_archive_dest_2='service=node1 lgwr async

valid_for=(online_logfiles,primary_role)

db_unique_name=node1'

log_archive_dest_state_1=enable

log_archive_dest_state_2=enable

fal_server=node1

fal_client=node2

db_file_name_convert='g:\database\oradata\node1','g:\database\oradata\node2'

log_file_name_convert='g:\database\oradata\node1','g:\database\oradata\node2'

主庫node1的引數

*.db_unique_name='NODE1'

*.fal_client='NODE1'

*.fal_server='NODE2'

*.log_archive_config='dg_config=(node1,node2)'

*.log_archive_dest_1='location=g:\database\oradata\node1\arch valid_for=(all_logfiles,all_roles) db_unique_name=node1'

*.log_archive_dest_2='service=node2 lgwr sync  valid_for=(online_logfiles,primary_role) db_unique_name=node2'

*.log_file_name_convert='g:\database\oradata\node2','g:\database\oradata\node1'


-------------------------------------------------------------------------

登陸PRIMARY資料庫:

[oracle@zhong ~]$ sqlplus "/ as sysdba"

SQL> SET SQLP 'NODE1> '

NODE1> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS

SESSIONS ACTIVE

NODE1> SELECT COUNT(*) FROM V$SESSION WHERE USERNAME IS NOT NULL;

1

雖然當前資料庫的狀態是SESSIONS ACTIVE而不是TO STANDBY,但是查詢V$SESSION會話,確認除了當前會話外,其他都是系統會話,那麼就可以在主庫進行SWITCHOVER切換了:

Node1:>alter database commit to switchover to physical  standby;

Node1:>shutdown immediate;

ORA-01507: database not mounted 

ORACLE instance shut down.

node1:>startup mount

重啟資料庫,啟動到MOUNT狀態,注意,9i及以前版本需要START NOMOUNT,然後ALTER DATABASE MOUNT STANDBY DATABASE。

 下面登陸STANDBY資料庫:

[oracle@zhong ~]$ sqlplus "/ as sysdba"

SQL> SET SQLP 'NODE2> '

Node2:>select switchover_status,database_role from v$database;

 SWITCHOVER_STATUS    DATABASE_ROLE

TO PRIMARY           PHYSICAL STANDBY

下面就可以將STANDBY資料庫切換到PRIMARY資料庫:

NODE2> alter database commit to switchover to primary;

node2:>select instance_name,status from v$instance;

 INSTANCE_NAME    STATUS

node2            STARTED

node2:>shutdown immediate

ORA-01507: database not mounted

ORACLE instance shut down.

node2:>startup

至此SWITCHOVER切換完成

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23073818/viewspace-716318/,如需轉載,請註明出處,否則將追究法律責任。

相關文章