1. If the standby database is in managed recovery mode, it will need to be cancelled and the instance shutdown using the IMMEDIATE option:
SQL> alter database recover managed standby database cancel;
Media recovery complete. SQL> shutdown immediate;
2. Startup the instance and then MOUNT the DB in standby mode
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
SQL> alter database mount standby database;
Database altered
3. If possible, archive the current redo logs on the primary database and transfer them (along with any remaining archived redo logs) to the standby machine. It is assumed that the primary database and host is not available.
4. Apply the primary database's archived logs by recovering the standby database.
SQL> recover standby database until cancel;
5. Cancel the recovery and activate the standby database. A CANCEL will need to be performed as this is Incomplete Recovery. In issuing the ALTER DATABASE ACTIVATE STANDBY DATABASE command, the standby bit in the control file is reset. This process takes the database back to nomount mode.
SQL> alter database activate standby database;
Database altered.
This process can take several minutes to complete, depending on the speed of the server.
6. Shutdown and restart the new primary database. This step ensures that all file headers are reset and clears all buffers. Remember that in the previous step when activating the standby database, that command puts the database back into nomount mode.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup open
ORACLE instance started.
Total System Global Area 252777660 bytes
Fixed Size 451772 bytes
Variable Size 218103808 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
You cannot copy online redo logs from the primary to the standby in a failover scenario.
7. Shutdown the standby instance and backup if possible, then open the database for normal use. Users can now connect to the "new" primary database.
The standby bit in the controlfile is now set, so you can never go back - the standby is now your primary database. Since the redo log sequence was reset when the standby was opened, it is a good idea to take a full backup at this point.
Cool!
ReplyDelete