Wednesday, 1 October 2014

How to Open Standby Database When Primary is Lost

Startup Mount

 [oracle@rac2 ~]$ sqlplus / as sysdba
 SQL*Plus: Release 10.2.0.3.0 - Production on Wed Feb 4 19:51:12 2009
 Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
 Connected to an idle instance.
 SQL> STARTUP MOUNT
 ORACLE instance started.
 Total System Global Area 218103808 bytes
 Fixed Size 1260984 bytes
 Variable Size 184549960 bytes
 Database Buffers 29360128 bytes
 Redo Buffers 2932736 bytes
 Database mounted.

Check Status

 SQL> SELECT OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE FROM V$DATABASE;
 OPEN_MODE PROTECTION_MODE DATABASE_ROLE
 ---------- -------------------- ----------------
 MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY

Recover if you have logs to apply
In this example the primary is lost and I don't have more archived logs to apply:

  SQL> RECOVER STANDBY DATABASE;
  ORA-00279: change 794348 generated at 12/29/2008 12:23:02 needed for thread 1
  ORA-00289: suggestion :
  /u01/app/oracle/oradata/dgfdb/archive/1_49_633452428.dbf
  ORA-00280: change 794348 for thread 1 is in sequence #49
  Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
  ORA-00308: cannot open archived log
  '/u01/app/oracle/oradata/dgfdb/archive/1_49_633452428.dbf'
  ORA-27037: unable to obtain file status
  Linux Error: 2: No such file or directory
  Additional information: 3
  SQL> !ls -l /u01/app/oracle/oradata/dgfdb/archive/
  total 31072
  -rw-r----- 1 oracle oinstall 1158656 Dec 29 11:31 1_37_633452428.dbf
  -rw-r----- 1 oracle oinstall 7385600 Dec 29 11:31 1_38_633452428.dbf
  -rw-r----- 1 oracle oinstall 4941824 Dec 29 11:31 1_39_633452428.dbf
  -rw-r----- 1 oracle oinstall 13739008 Dec 29 11:31 1_40_633452428.dbf
  -rw-r----- 1 oracle oinstall 2272256 Dec 29 11:50 1_41_633452428.dbf
  -rw-r----- 1 oracle oinstall 1024 Dec 29 11:51 1_42_633452428.dbf
  -rw-r----- 1 oracle oinstall 89088 Dec 29 11:51 1_43_633452428.dbf
  -rw-r----- 1 oracle oinstall 1847296 Dec 29 12:18 1_44_633452428.dbf
  -rw-r----- 1 oracle oinstall 135680 Dec 29 12:18 1_45_633452428.dbf
  -rw-r----- 1 oracle oinstall 67584 Dec 29 12:19 1_46_633452428.dbf
  -rw-r----- 1 oracle oinstall 34816 Dec 29 12:22 1_47_633452428.dbf
  -rw-r----- 1 oracle oinstall 2048 Dec 29 12:22 1_48_633452428.dbf

Finish the Recovery process

 SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
 Database altered.

Activate the Standby Database

 SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
 Database altered.

Check the new status

 SQL> SELECT OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE FROM V$DATABASE;
 OPEN_MODE PROTECTION_MODE DATABASE_ROLE
 ---------- -------------------- ----------------
 MOUNTED MAXIMUM PERFORMANCE PRIMARY

Open the Database

 SQL> ALTER DATABASE OPEN;
 Database altered.
 SQL> SELECT OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE FROM V$DATABASE;
 OPEN_MODE PROTECTION_MODE DATABASE_ROLE
 ---------- -------------------- ----------------
 READ WRITE MAXIMUM PERFORMANCE PRIMARY

No comments:

Post a Comment