1. [PRIMARY] Switch log file on primary database.
SQL>alter system switch logfile;
2. [PRIMARY] Check switchover status before switching database.
SQL>select switchover_status from v$database;
You must see “TO_STANDBY” as result.
3. [PRIMARY] Switch primary database to standby database.
SQL>alter database commit to switchover to physical standby with session shutdown;
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
4. [PRIMARY] Defer for archive log apply. Because I didn’t set my standby database as primary yet.
SQL>alter system set log_archive_dest_state_2=defer;
5. [Standby] Switch standby database to primary. Check switchover status before switching database.
SQL>select switchover_status from v$database;
You must see “TO_PRIMARY” as result. Now let’s swtich
SQL>alter database commit to switchover to primary;
SQL>shutdown immediate;
SQL>startup;
Our switchover process is successfully completed .
6. [PRIMARY] Start real-time recovery process..
SQL>recover managed standby database using current logfile disconnect;
Finally let’s open our database with “Read Only with Apply”.
SQL>recover managed standby database cancel;
SQL>alter database open;
SQL>recover managed standby database using current logfile disconnect;
FAILOVER:
In short, the failover is the deformation of the production (primary) database and activating standby database as the primary. It is not reversible. When enabled, re-create the standby database. What to do in case of failover:
(Important note: PRIMARY is the primary server and Standby is the standby server)
1. [PRIMARY] If the primary database is accessible and running, then it must provided to send redo buffer to the standby database.
SQL> alter system flush redo to standby_db_name;
SQL>alter system archive log current;
If you don’t receive an error, you can continue with step 5th. In this case, the system can be opened by zero data loss. If you receive an error, We continue with step 2 to open the system at least data loss.
2. [Standby] We must run the following query to learn last applied archive log sequence number.
SQL> SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;
3. [PRIMARY’dan Standby’ye] 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 '/oracle/ora11g/dbs/arch/ TALIP_991834413_1_102.arc ';
4. [Standby] Check the standby database for redo gap. If there is a gap then we must copy archive log files and register.
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
SQL> alter database register physical logfile '/oracle/ora11g/dbs/arch/ TALIP_991834413_1_101.arc ';
As a result of the above query until it returns to zero.
5. [Standby] Stop the redo apply process in standby database.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
6. [Standby] Finish to apply archive logs copied from primary.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
If you get an error, it means there are redo logs not applied. Consider 2th and 4th steps. You can also continue with following command;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
In this situation you can open database in 8th step. If you get no error, continue with 7th step.
7. [Standby] Switch standby database to primary database.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
8. [Standby] Open database.
SQL> ALTER DATABASE OPEN;
After opening standby database as primary with failover you must take full backup.
SQL>alter system switch logfile;
2. [PRIMARY] Check switchover status before switching database.
SQL>select switchover_status from v$database;
You must see “TO_STANDBY” as result.
3. [PRIMARY] Switch primary database to standby database.
SQL>alter database commit to switchover to physical standby with session shutdown;
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
4. [PRIMARY] Defer for archive log apply. Because I didn’t set my standby database as primary yet.
SQL>alter system set log_archive_dest_state_2=defer;
5. [Standby] Switch standby database to primary. Check switchover status before switching database.
SQL>select switchover_status from v$database;
You must see “TO_PRIMARY” as result. Now let’s swtich
SQL>alter database commit to switchover to primary;
SQL>shutdown immediate;
SQL>startup;
Our switchover process is successfully completed .
6. [PRIMARY] Start real-time recovery process..
SQL>recover managed standby database using current logfile disconnect;
Finally let’s open our database with “Read Only with Apply”.
SQL>recover managed standby database cancel;
SQL>alter database open;
SQL>recover managed standby database using current logfile disconnect;
FAILOVER:
In short, the failover is the deformation of the production (primary) database and activating standby database as the primary. It is not reversible. When enabled, re-create the standby database. What to do in case of failover:
(Important note: PRIMARY is the primary server and Standby is the standby server)
1. [PRIMARY] If the primary database is accessible and running, then it must provided to send redo buffer to the standby database.
SQL> alter system flush redo to standby_db_name;
SQL>alter system archive log current;
If you don’t receive an error, you can continue with step 5th. In this case, the system can be opened by zero data loss. If you receive an error, We continue with step 2 to open the system at least data loss.
2. [Standby] We must run the following query to learn last applied archive log sequence number.
SQL> SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;
3. [PRIMARY’dan Standby’ye] 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 '/oracle/ora11g/dbs/arch/ TALIP_991834413_1_102.arc ';
4. [Standby] Check the standby database for redo gap. If there is a gap then we must copy archive log files and register.
SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
SQL> alter database register physical logfile '/oracle/ora11g/dbs/arch/ TALIP_991834413_1_101.arc ';
As a result of the above query until it returns to zero.
5. [Standby] Stop the redo apply process in standby database.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
6. [Standby] Finish to apply archive logs copied from primary.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
If you get an error, it means there are redo logs not applied. Consider 2th and 4th steps. You can also continue with following command;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
In this situation you can open database in 8th step. If you get no error, continue with 7th step.
7. [Standby] Switch standby database to primary database.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
8. [Standby] Open database.
SQL> ALTER DATABASE OPEN;
After opening standby database as primary with failover you must take full backup.