A failover is typically used only when the Oracle primary database becomes unavailable
A failover is typically used only when the primary database becomes unavailable, and there is no possibility of restoring it to service within a reasonable period of time
Performing a Failover to a Physical Standby Database –
Step 01- Flush any unsent redo from the primary database to the target standby database
If the primary database can be mounted, it may be possible to flush any unsent archived and current redo from the primary database to the standby database. If this operation is successful, a zero data loss failover is possible even if the primary database is not in a zero data loss data protection mode. Mount, but do not open primary database. If primary database cannot be mounted go to step 2. On Primary database ( if accessible during real disaster )
SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;
For target_db_name, specify the DB_UNIQUE_NAME of the standby database that is to receive the redo flushed from the primary database. This statement flushes any unsent redo from the primary database to the standby database, and waits for that redo to be applied to the standby database. If this statement completes without any errors,
go to Step 3. If the statement completes with any error, or
if it must be stopped because you cannot wait any longer for the statement to complete, continue with Step 2.
Step 2 – Identify and resolve any archived redo log gaps On Standby database
SQL> SELECT DATABASE_MODE,RECOVERY_MODE,GAP_STATUS FROM V$ARCHIVE_DEST_STATUS;
SQL> select process,pid,status,thread#,sequence#,block#,blocks from v$managed_standby;
Wait for logs indicates it’s not applied to DR.
If possible, copy any missing archived redo log files to the target standby database from the primary database.
If primary database is not accessible then there will be data loss.
We must run the following query to learn last applied archive log sequence number.
SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;
If you can access archive logs which are not copied to standby then copy archives to standby. After copy archive log files we must register them to standby database.
This operation must be done for every thread.
SQL> alter database register physical logfile '/b01/fra/tstssby_991834413_1_102.arc ';
Check the standby database for redo gap. If there is a gap then we must copy archive log files and register.
As a result of the above query until it returns to zero.
stop the redo apply process in standby database.
3
Step 3 – Stop Redo Apply
4
Step 4 – Finish applying all received Redo Data
Verify that the target standby database is ready to become a primary database
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
TO PRIMARY
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
Database altered.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
SQL> ALTER DATABASE OPEN;
Database altered.
SQL>
SQL> select status,instance_name,database_role from v$database,v$instance;
STATUS INSTANCE_NAME DATABASE_ROLE
------------ ---------------- ----------------
OPEN TSTSBY PRIMARY
5 On Standby database
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
If this statement completes with error
If the error condition cannot be resolved, a failover can still be performed (with some data loss) by issuing the following SQL statement On Standby database
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
Open the new primary database On Standby database
SQL> ALTER DATABASE OPEN;
Convert the database to a physical standby database
1
On Old Primary database
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
This statement will dismount the database after successfully converting the control file to a standby control file
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
2
On New Primary database
query to see the current state of the archive destinations
SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION, ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;
If necessary, enable the destination
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_n=ENABLE;
Perform a log switch to ensure the standby database begins receiving redo data from the new primary database
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION, ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;
Start Redo Apply on the new physical standby database
On New Physical standby database
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Performing a Failover to a Physical Standby Database –
Step 01- Flush any unsent redo from the primary database to the target standby database
If the primary database can be mounted, it may be possible to flush any unsent archived and current redo from the primary database to the standby database. If this operation is successful, a zero data loss failover is possible even if the primary database is not in a zero data loss data protection mode. Mount, but do not open primary database. If primary database cannot be mounted go to step 2. On Primary database ( if accessible during real disaster )
SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;
For target_db_name, specify the DB_UNIQUE_NAME of the standby database that is to receive the redo flushed from the primary database. This statement flushes any unsent redo from the primary database to the standby database, and waits for that redo to be applied to the standby database. If this statement completes without any errors,
go to Step 3. If the statement completes with any error, or
if it must be stopped because you cannot wait any longer for the statement to complete, continue with Step 2.
Step 2 – Identify and resolve any archived redo log gaps On Standby database
SQL> SELECT DATABASE_MODE,RECOVERY_MODE,GAP_STATUS FROM V$ARCHIVE_DEST_STATUS;
SQL> select process,pid,status,thread#,sequence#,block#,blocks from v$managed_standby;
Wait for logs indicates it’s not applied to DR.
If possible, copy any missing archived redo log files to the target standby database from the primary database.
If primary database is not accessible then there will be data loss.
We must run the following query to learn last applied archive log sequence number.
SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;
If you can access archive logs which are not copied to standby then copy archives to standby. After copy archive log files we must register them to standby database.
This operation must be done for every thread.
SQL> alter database register physical logfile '/b01/fra/tstssby_991834413_1_102.arc ';
Check the standby database for redo gap. If there is a gap then we must copy archive log files and register.
As a result of the above query until it returns to zero.
stop the redo apply process in standby database.
3
Step 3 – Stop Redo Apply
4
Step 4 – Finish applying all received Redo Data
Verify that the target standby database is ready to become a primary database
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
TO PRIMARY
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
Database altered.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
Database altered.
SQL> ALTER DATABASE OPEN;
Database altered.
SQL>
SQL> select status,instance_name,database_role from v$database,v$instance;
STATUS INSTANCE_NAME DATABASE_ROLE
------------ ---------------- ----------------
OPEN TSTSBY PRIMARY
5 On Standby database
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
If this statement completes with error
If the error condition cannot be resolved, a failover can still be performed (with some data loss) by issuing the following SQL statement On Standby database
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
Open the new primary database On Standby database
SQL> ALTER DATABASE OPEN;
Convert the database to a physical standby database
1
On Old Primary database
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
This statement will dismount the database after successfully converting the control file to a standby control file
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
2
On New Primary database
query to see the current state of the archive destinations
SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION, ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;
If necessary, enable the destination
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_n=ENABLE;
Perform a log switch to ensure the standby database begins receiving redo data from the new primary database
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION, ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;
Start Redo Apply on the new physical standby database
On New Physical standby database
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Comments
Post a Comment