Tuesday, April 22, 2014

RMAN-06457 UNTIL SCN is ahead of last SCN in archived logs

#!/bin/ksh

export ORACLE_SID=OIDTEST

rman msglog restore_OIDTEST.log append<< EOF
connect target sys/@OID
connect auxiliary /
run
{
allocate auxiliary channel ch01 type disk;
allocate auxiliary channel ch02 type disk;
allocate auxiliary channel ch03 type disk;
allocate auxiliary channel ch04 type disk;
set until time "to_date('06-AUG-2012 10:00:00','DD-MON-YYYY HH24:MI:SS')";
duplicate target database to OIDTEST;
}
exit
EOF



RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/07/2012 11:12:13
RMAN-06457: UNTIL SCN (488979215) is ahead of last SCN in archived logs (486144524)



When I looked at the SCN's they all still reflecting the old chnages/date and my restore is trying to go beyond these SCN's.


SQL> select thread#, status, enabled, checkpoint_time, checkpoint_change# from v$thread;

   THREAD# STATUS ENABLED  CHECKPOIN CHECKPOINT_CHANGE#
---------- ------ -------- --------- ------------------
         1 OPEN   PUBLIC   03-AUG-12          486144524
         2 OPEN   PUBLIC   05-AUG-12          488215686
         3 OPEN   PUBLIC   04-AUG-12          486909043


Do a check point.

SQL> alter system checkpoint;

System altered.

SQL> select thread#, status, enabled, checkpoint_time, checkpoint_change# from v$thread;

   THREAD# STATUS ENABLED  CHECKPOIN CHECKPOINT_CHANGE#
---------- ------ -------- --------- ------------------
         1 OPEN   PUBLIC   07-AUG-12          490100101
         2 OPEN   PUBLIC   07-AUG-12          490100101
         3 OPEN   PUBLIC   07-AUG-12          490100100


Now check what you have in the v$log. If they still reflect the old Change#'s then switch logfiles until all the threads are changed.




SQL> alter system switch logfile;

System altered.



SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.


SQL>  alter system switch logfile;

System altered.

SQL>  alter system switch logfile;

System altered.


SQL>

Restart the duplication process..happy duplicating..

DG database recovery


1.Backup  ---
rman target /  

run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup as compressed backupset archivelog from time "to_date('21.04.2014 21:00:00','DD.MM.YYYY HH24:Mi:SS')"   until time "to_date('21.04.2014 22:13:14','DD.MM.YYYY HH24:Mi:SS')" format '/home/lingesan/arch_%U';
}

2.Copy the backup pieces and   new standby controlfile to DG  

3.Restore  ----  
run
{
catalog start with '/home/lingesan';
allocate channel c1 type disk ;
restore archivelog from time "to_date('21.04.2014 21:00:00','DD.MM.YYYY HH24:Mi:SS')"   until time "to_date('21.04.2014 22:13:14','DD.MM.YYYY HH24:Mi:SS')";
}

ORA-01586 ORA-39701 database must be mounted EXCLUSIVE and not open for this operation

Dropping the database :

 
Mount the database in restrict mode:
 SQL> startup mount restrict;
ORACLE instance started.


Database mounted.

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
dbm1

SQL> drop database;

Database dropped.

What if you get the below error:


SQL> startup mount  restrict;
ORACLE instance started.


Database mounted.
SQL> drop database;
drop database
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation

Even the startup upgrade will fail:

SQL> startup upgrade
ORACLE instance started.

Total System Global Area 3206836224 bytes
Fixed Size                  2232640 bytes
Variable Size             704646848 bytes
Database Buffers         2348810240 bytes
Redo Buffers              151146496 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-39701: database must be mounted EXCLUSIVE for UPGRADE or DOWNGRADE
Process ID: 46501
Session ID: 652 Serial number: 3


Then mostly likely you are destroying a RAC database and you need to change the cluster_database=FALSE.

SQL> alter system set cluster_database=FALSE scope=spfile;


System altered.

SQL> startup mount restrict;
ORACLE instance started.


Redo Buffers              151146496 bytes
Database mounted.

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
dbm1

SQL> drop database;

Database dropped.