Tuesday, September 20, 2016

Restore, Recover and Open Oracle Database with Missing REDO

After you finish Resote & Recover DB. But you can not open DB for some reason. The primary is that you don't have enought REDO.
you can use this sql to check the fuzziness and PIT (Point In Time) of the datafiles after an incomplete recovery:

select fuzzy, status, checkpoint_change#, to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as checkpoint_time, count(*)
from v$datafile_header
group by fuzzy, status, checkpoint_change#, checkpoint_time
order by fuzzy, status, checkpoint_change#, checkpoint_time;

Recovering without Consistency
SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;
SQL> alter system set undo_management='MANUAL' scope=spfile;
SQL> shutdown abort;
SQL> startup mount;
SQL> alter database open resetlogs;
SQL> create undo tablespace UNDOTBS2 datafile size 50M;
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile;

Select for rollback segments
SQL> set linesize 150
SQL> select  segment_name,status from  dba_rollback_segs where    status = 'NEEDS RECOVERY';
SQL> select owner, segment_name, tablespace_name, status from dba_rollback_segs where tablespace_name like '%2';

Create pfile and edit some parameter.  The values for rollback_segments paramet come from above sql result:
SQL> create pfile from spfile
edit your pfile as below:
*.undo_management='MANUAL'
*.undo_tablespace='SYSTEM'
*._offline_rollback_segments=(_SYSSMU137_4114137959$,_SYSSMU156_2905474506$,_SYSSMU159_3144578331$,_SYSSMU166_3380345480$)
*._corrupted_rollback_segments=(_SYSSMU137_4114137959$,_SYSSMU156_2905474506$,_SYSSMU159_3144578331$,_SYSSMU166_3380345480$)

SQL> shutdown abort;
SQL> startup pfile='/u01/your_pfile.ora';
SQL> drop tablespace undotbs2 including contents and datafiles;
SQL> alter system set "_allow_resetlogs_corruption"=false scope=spfile;
SQL> alter system set undo_management='AUTO' scope=spfile;
SQL> starup force;

No comments:

Post a Comment