The current status is dg1 as the master database, and the slave database is dg2.
First check the status of the Master/Slave database:
Dg1
SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS---------------- ---------- --------------------PRIMARY READ WRITE SESSIONS ACTIVE
Dg2
SQL> select database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS---------------- ---------- --------------------PHYSICAL STANDBY MOUNTED NOT ALLOWED
Perform the following steps on the current primary database of dg1:
SQL> alter database commit to switchover to physical standby with session shutdown;Database altered.SQL> shutdown immediate;ORA-01507: database not mountedORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 390070272 bytesFixed Size 2021024 bytesVariable Size 150997344 bytesDatabase Buffers 234881024 bytesRedo Buffers 2170880 bytesDatabase mounted.SQL> select switchover_status from v$database;SWITCHOVER_STATUS--------------------TO PRIMARY
The following steps are performed on the current standby database of dg2:
SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS--------- ---------------- ---------- --------------------ORCLDB PHYSICAL STANDBY MOUNTED TO PRIMARYSQL> select switchover_status from v$database;SWITCHOVER_STATUS--------------------TO PRIMARYSQL> alter database commit to switchover to primary;Database altered.SQL> alter database open;Database altered.SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;NAME DATABASE_ROLE OPEN_MODE SWITCHOVER_STATUS--------- ---------------- ---------- --------------------ORCLDB PRIMARY READ WRITE SESSIONS ACTIVE
The above operations have completed the master-slave switchover. Now dg2 is the master database and dg1 is the slave database. Next, we will make several Log Changes on the current master database dg2, check whether dg1 can be synchronized.
View archived logs on dg1:
SQL> select registrar, creator thread #, sequence #, first_change #, next_change # from v $ archived_log; registr thread # SEQUENCE # FIRST_CHANGE # NEXT_CHANGE # ------- ------------------- ------------ FGRD 29 586174 586196dg2 after several log switches, SQL> select * from v $ log; GROUP # THREAD # SEQUENCE # bytes members arc status FIRST_CHANGE # FIRST_TIM ---------- --- ---------------- ----------- 1 1 36 52428800 1 no current 586469 05-JAN-142 1 34 52428800 1 YES INACTIVE 586464 05-JAN-143 1 35 52428800 1 yes inactive 586467 05-JAN-14
It can be seen that the log has reached 36, so we should apply the log on dg1 to log 35;
Perform the following verification:
SQL> alter database recover managed standby database disconnect from session;Database altered.SQL> select registrar,creator thread#,sequence#,first_change#,next_change# from v$archived_log;REGISTR THREAD# SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#------- ------- ---------- ------------- ------------RFS ARCH 34 586464 586467RFS ARCH 35 586467 586469
The above master-slave switchover process has been successfully completed.
This article is from the "Abu" blog, please be sure to keep this source http://carefree.blog.51cto.com/5771371/1351018