Tuesday, May 28, 2013

Converting standby Database into Primary Database

In a case when your Production Primary Server got crashed and you have only with your standby database server which is up and running fine. To deal with this you can convert your standby database into Production database. 
Note. Once you convert standby database into Primary database you can't revert back this process.


SQL> select  GROUP#,STATUS,TYPE,MEMBER  from v$logfile;

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
         3         ONLINE
/u01/app/oracle/oradata/db1/redo03.log

         2         ONLINE
/u01/app/oracle/oradata/db1/redo02.log

         1         ONLINE
/u01/app/oracle/oradata/db1/redo01.log

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
DB1       READ ONLY WITH APPLY PHYSICAL STANDBY

SQL> select process from v$managed_standby;

PROCESS
---------
ARCH
ARCH
ARCH
ARCH
RFS
RFS
RFS
MRP0

8 rows selected.

Issue the command to finish the recovery process.
SQL> recover managed standby database finish;
Media recovery complete.

Excerpt from alert log while issue the above command.

ALTER DATABASE RECOVER  managed standby database finish
Terminal Recovery: request posted (db1)
Tue May 28 12:35:07 2013
krsv_proc_kill: Killing 3 processes (all RFS, wait for I/O)
Begin: Standby Redo Logfile archival
End: Standby Redo Logfile archival
Terminal Recovery timestamp is '05/28/2013 12:35:09'
Terminal Recovery: applying standby redo logs.
Terminal Recovery: thread 1 seq# 211 redo required
Media Recovery Waiting for thread 1 sequence 211
Terminal Recovery: End-Of-Redo log allocation
Terminal Recovery: standby redo logfile 4 created '/u01/app/oracle/admin/db1/arch/1_0_812203684.dbf'
This standby redo logfile is being created as part of the
failover operation.  This standby redo logfile should be
deleted after the switchover to primary operation completes.
Media Recovery Log /u01/app/oracle/admin/db1/arch/1_0_812203684.dbf
Terminal Recovery: log 4 reserved for thread 1 sequence 211
Recovery of Online Redo Log: Thread 1 Group 4 Seq 211 Reading mem 0
  Mem# 0: /u01/app/oracle/admin/db1/arch/1_0_812203684.dbf
Identified End-Of-Redo (failover) for thread 1 sequence 211 at SCN 0xffff.ffffffff
Incomplete Recovery applied until change 3099725 time 05/28/2013 12:30:15
MRP0: Media Recovery Complete (db1)
Terminal Recovery: successful completion
Tue May 28 12:35:09 2013
ARCH: Archival stopped, error occurred. Will continue retrying
ORACLE Instance db1 - Archival Error
ORA-16014: log 4 sequence# 211 not archived, no available destinations
ORA-00312: online log 4 thread 1: '/u01/app/oracle/admin/db1/arch/1_0_812203684.dbf'
Forcing ARSCN to IRSCN for TR 0:3099725
Attempt to set limbo arscn 0:3099725 irscn 0:3099725
Resetting standby activation ID 1406069595 (0x53ceeb5b)
MRP0: Background Media Recovery process shutdown (db1)
Terminal Recovery: completion detected (db1)
Completed: ALTER DATABASE RECOVER  managed standby database finish
Tue May 28 12:35:58 2013
RFS[3]: Assigned to RFS process 15923
RFS[3]: No connections allowed during/after terminal recovery.
Tue May 28 12:36:41 2013

SQL> select process from v$managed_standby;

PROCESS
---------
ARCH
ARCH
ARCH
ARCH

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
DB1       READ ONLY            PHYSICAL STANDBY

SQL> select  GROUP#,STATUS,TYPE,MEMBER  from v$logfile;

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
         3         ONLINE
/u01/app/oracle/oradata/db1/redo03.log

         2         ONLINE
/u01/app/oracle/oradata/db1/redo02.log

         1         ONLINE
/u01/app/oracle/oradata/db1/redo01.log


    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
-------------------------------------------------------------------------------
         4         STANDBY
/u01/app/oracle/admin/db1/arch/1_0_812203684.dbf

Now Activate the standby database for Primary database.

SQL> alter database activate physical standby database;
Database altered.

Excerpt from alert log.
alter database activate physical standby database
ALTER DATABASE ACTIVATE [PHYSICAL] STANDBY DATABASE (db1)
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
Active process 13155 user 'oracle' program 'oracle@test.cybage.com (TNS V1-V3)'
Active process 13155 user 'oracle' program 'oracle@test.cybage.com (TNS V1-V3)'
..........
Active process 13155 user 'oracle' program 'oracle@test.cybage.com (TNS V1-V3)'
Active process 13155 user 'oracle' program 'oracle@test.cybage.com (TNS V1-V3)'
CLOSE: all sessions shutdown successfully.
Tue May 28 12:36:45 2013
SMON: disabling cache recovery
Begin: Standby Redo Logfile archival
Tue May 28 12:36:45 2013
Archiver process freed from errors. No longer stopped
End: Standby Redo Logfile archival
Standby terminal recovery start SCN: 3099724
RESETLOGS after incomplete recovery UNTIL CHANGE 3099725
Archived Log entry 7 added for thread 1 sequence 211 ID 0x53ceeb5b dest 1:
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/db1/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 1 /u01/app/oracle/oradata/db1/redo01.log
Clearing online log 1 of thread 1 sequence number 211
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/db1/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/db1/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 1 complete
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/db1/redo02.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 /u01/app/oracle/oradata/db1/redo02.log
Clearing online log 2 of thread 1 sequence number 210
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/db1/redo02.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/db1/redo02.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 complete
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/db1/redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 3 /u01/app/oracle/oradata/db1/redo03.log
Clearing online log 3 of thread 1 sequence number 211
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/db1/redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/sdb1/db1/trace/db1_ora_15840.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/db1/redo03.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 3 complete
Online log /u01/app/oracle/oradata/db1/redo01.log: Thread 1 Group 1 was previously cleared
Online log /u01/app/oracle/oradata/db1/redo02.log: Thread 1 Group 2 was previously cleared
Online log /u01/app/oracle/oradata/db1/redo03.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 3099723
Tue May 28 12:36:47 2013
Setting recovery target incarnation to 3
WARNING: STANDBY_FILE_MANAGEMENT initialization parameter is
not set to the value "AUTO".
This may cause recovery of the standby database to terminate
prior to applying all available redo data.
It may be necessary to use the ALTER DATABASE CREATE DATAFILE
command to add datafiles created on the primary database.
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the paramete                                                      r file.
ACTIVATE STANDBY: Complete - Database mounted as primary
Completed: alter database activate physical standby database
Tue May 28 12:37:32 2013
alter database open
Tue May 28 12:37:32 2013
Assigning activation ID 1410385808 (0x5410c790)
Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED
Destination LOG_ARCHIVE_DEST_2 no longer supports SYNCHRONIZATION
Thread 1 advanced to log sequence 2 (thread open)
Thread 1 opened at log sequence 2
  Current log# 2 seq# 2 mem# 0: /u01/app/oracle/oradata/db1/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Tue May 28 12:37:32 2013
SMON: enabling cache recovery
Tue May 28 12:37:33 2013
PING[ARC2]: Heartbeat failed to connect to standby 'db1'. Error is 16009.
[15840] Successfully onlined Undo Tablespace 5.
Undo initialization finished serial:0 start:424910974 end:424912014 diff:1040 (10 seconds)
Dictionary check beginning
Dictionary check complete
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is WE8MSWIN1252
Tue May 28 12:37:34 2013
idle dispatcher 'D000' terminated, pid = (17, 1)
No Resource Manager plan active
Starting background process SMCO
Tue May 28 12:37:34 2013
SMCO started with pid=19, OS id=15935
Starting background process QMNC
Tue May 28 12:37:37 2013
QMNC started with pid=25, OS id=15937
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Completed: alter database open
Tue May 28 12:37:44 2013
Starting background process CJQ0
Tue May 28 12:37:44 2013
CJQ0 started with pid=28, OS id=15953
Tue May 28 12:37:46 2013
Active Session History (ASH) performed an emergency flush. This may mean that ASH is undersized. If eme                                                      rgency flushes are a recurring issue, you may consider increasing ASH size by setting the value of _ASH                                                      _SIZE to a sufficiently large value. Currently, ASH size is 2097152 bytes. Both ASH size and the total                                                       number of emergency flushes since instance startup can be monitored by running the following query:
 select total_size,awr_flush_emergency_count from v$ash_info;
Tue May 28 12:38:34 2013
ARC2: STARTING ARCH PROCESSES
Tue May 28 12:38:34 2013
ARC4 started with pid=27, OS id=15969
ARC4: Archival started
ARC2: STARTING ARCH PROCESSES COMPLETE
PING[ARC2]: Heartbeat failed to connect to standby 'db1'. Error is 16009.
Shutting down archive processes


SQL>  select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
DB1       MOUNTED              PRIMARY

SQL> alter database open;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
DB1       READ WRITE           PRIMARY

No comments:

Post a Comment