Saturday, 7 July 2012

How to find the Lost logfile of RMAN?

How to find the Lost logfile of RMAN?

If we lost the RMAN logfile and want to regenerate the logfile, we can find it out from the store of  database. As it is stored in the database and if database went down all data will lost.

We can find it out by using below query:

col STATUS format a9
select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi:ss') start_time
from V$RMAN_BACKUP_JOB_DETAILS
order by start_time
/
set pages 0
set lines 130
set trims on
set feedback off
set ver off
define sess_key=&session_key
spool rman_&sess_key..output
select output
from v$rman_output
where session_key = &sess_key
order by recid;
/
spool off
prompt Your outputfile is called rman_&sess_key..output
exit

==================================
output:

SQL> @saurabh.sql
SESSION_KEY INPUT_TYPE    STATUS    START_TIME
----------- ------------- --------- -----------------
         71 CONTROLFILE   COMPLETED 06/08/12 23:00:46
         76 DB FULL       COMPLETED 06/09/12 18:00:09
         81 DB FULL       COMPLETED 06/10/12 18:00:09
         86 DB FULL       COMPLETED 06/11/12 18:00:08
         91 DB FULL       COMPLETED 06/12/12 18:00:09
         96 DB FULL       COMPLETED 06/13/12 18:00:07
        101 DB FULL       COMPLETED 06/14/12 18:00:07
        106 DB FULL       COMPLETED 06/15/12 18:00:09
        111 DB FULL       COMPLETED 06/16/12 18:00:09
        116 DB FULL       COMPLETED 06/17/12 18:00:08
        121 DB FULL       COMPLETED 06/18/12 18:00:07
SESSION_KEY INPUT_TYPE    STATUS    START_TIME
----------- ------------- --------- -----------------
        126 DB FULL       COMPLETED 06/19/12 18:00:07
        131 DB FULL       COMPLETED 06/20/12 18:00:07
        136 DB FULL       COMPLETED 06/21/12 18:00:08
        141 DB FULL       COMPLETED 06/22/12 18:00:08
        146 DB FULL       COMPLETED 06/23/12 18:00:09
        151 DB FULL       COMPLETED 06/24/12 18:00:15
        156 DB FULL       COMPLETED 06/25/12 18:00:08
        161 DB FULL       COMPLETED 06/26/12 18:00:08
        166 DB FULL       COMPLETED 06/27/12 18:00:08
        171 DB FULL       COMPLETED 06/28/12 18:00:07
        176 DB FULL       COMPLETED 06/29/12 18:00:09
SESSION_KEY INPUT_TYPE    STATUS    START_TIME
----------- ------------- --------- -----------------
        181 DB FULL       COMPLETED 06/30/12 18:00:08
        186 DB FULL       COMPLETED 07/01/12 18:00:08
        191 DB FULL       COMPLETED 07/02/12 18:00:12
        196 DB FULL       COMPLETED 07/03/12 18:00:09
        201 DB FULL       COMPLETED 07/04/12 18:00:08
        206 DB FULL       COMPLETED 07/05/12 18:00:09
        211 DB FULL       COMPLETED 07/06/12 18:00:11
29 rows selected.
Enter value for session_key: 211

------
-----

hannel d2: backup set complete, elapsed time: 00:02:55
Finished backup at 06-JUL-12
released channel: d2
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=27 device type=DISK
List of Archived Log Copies for database with db_unique_name GFSDEV
=====================================================================
Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
165     1    165     A 04-JUL-12
        Name: /u01/apps/gfsdevdb/11.2.0/dbs/arch1_165_784089575.dbf
166     1    166     A 04-JUL-12
        Name: /u01/apps/gfsdevdb/11.2.0/dbs/arch1_166_784089575.dbf
167     1    167     A 04-JUL-12
        Name: /u01/apps/gfsdevdb/11.2.0/dbs/arch1_167_784089575.dbf
168     1    168     A 04-JUL-12
        Name: /u01/apps/gfsdevdb/11.2.0/dbs/arch1_168_784089575.dbf
deleted archived log
archived log file name=/u01/apps/gfsdevdb/11.2.0/dbs/arch1_165_784089575.dbf RECID=165 STAMP=787770523
deleted archived log
archived log file name=/u01/apps/gfsdevdb/11.2.0/dbs/arch1_166_784089575.dbf RECID=166 STAMP=787791323
deleted archived log
archived log file name=/u01/apps/gfsdevdb/11.2.0/dbs/arch1_167_784089575.dbf RECID=167 STAMP=787791325
deleted archived log
archived log file name=/u01/apps/gfsdevdb/11.2.0/dbs/arch1_168_784089575.dbf RECID=168 STAMP=787829361
Deleted 4 objects

Starting backup at 06-JUL-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 06-JUL-12
channel ORA_DISK_1: finished piece 1 at 06-JUL-12
piece handle=/backup/GFSDEV_backup/database/GFSDEV_20120706_i7nfeodq_1_1.ctl.bkp tag=TAG20120706T225906 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 06-JUL-12


Your outputfile is called rman_211.output