Thursday, February 15, 2018

Recover system datafile until sequence



SQL> select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1       8196 2139083                  63
         2          4 2139083                  63
         3          4 2139083                  63
         4          4 2139083                  63
         5          4 2139083                  63
         7          4 2139083                  63

6 rows selected.

SQL>


SQL> select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1       8196 2139083                  63
         2          4 2139083                  63
         3          4 2139083                  63
         4          4 2139083                  63
         5          4 2139083                  63
         7          4 2139083                  63

6 rows selected.

SQL> alter system switch logfile;

System altered.

SQL> !
[oracle@localhost DUCAT]$ cd /u01/app/oracle/oradata/
[oracle@localhost oradata]$ ls
ducat  test
[oracle@localhost oradata]$
[oracle@localhost oradata]$ cd ducat/
[oracle@localhost ducat]$ ls
control01.ctl  example01.dbf  fda01.dbf  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf
[oracle@localhost ducat]$
[oracle@localhost ducat]$ mv system01.dbf system01.dbf_bkp
[oracle@localhost ducat]$ ls -lrt
total 2570540
-rw-r----- 1 oracle oinstall 173023232 Feb 15 05:16 temp01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb 15 05:17 redo02.log
-rw-r----- 1 oracle oinstall 671096832 Feb 15 05:20 sysaux01.dbf
-rw-r----- 1 oracle oinstall 363077632 Feb 15 05:20 example01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb 15 05:20 fda01.dbf
-rw-r----- 1 oracle oinstall  32776192 Feb 15 05:20 users01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb 15 05:25 redo03.log
-rw-r----- 1 oracle oinstall 817897472 Feb 15 05:25 system01.dbf_bkp
-rw-r----- 1 oracle oinstall 424681472 Feb 15 05:25 undotbs01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb 15 05:25 redo01.log
-rw-r----- 1 oracle oinstall   9781248 Feb 15 05:26 control01.ctl
[oracle@localhost ducat]$
[oracle@localhost ducat]$ exit
exit

SQL>
SQL>
SQL>
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1       8196 2139322                  66
         2          4 2139322                  66
         3          4 2139322                  66
         4          4 2139322                  66
         5          4 2139322                  66
         7          4 2139322                  66

6 rows selected.

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost DUCAT]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 15 05:27:34 2018

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size                  2259840 bytes
Variable Size             654312576 bytes
Database Buffers          381681664 bytes
Redo Buffers                5632000 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/ducat/system01.dbf'


SQL> select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1          0 0                         0
         2          0 2139751                  66
         3          0 2139751                  66
         4          0 2139751                  66
         5          0 2139751                  66
         7          0 2139751                  66

6 rows selected.

SQL> shut immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost DUCAT]$ 

SQL> select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1       8192 2139083                  63
         2          0 2139751                  66
         3          0 2139751                  66
         4          0 2139751                  66
         5          0 2139751                  66
         7          0 2139751                  66

6 rows selected.



restore system datafile here





rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 15 05:28:12 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area    1043886080 bytes

Fixed Size                     2259840 bytes
Variable Size                654312576 bytes
Database Buffers             381681664 bytes
Redo Buffers                   5632000 bytes

RMAN> restore datafile 1;

Starting restore at 15-FEB-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/ducat/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DUCAT/backupset/2018_02_15/o1_mf_nnndf_TAG20180215T052016_f89lst35_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DUCAT/backupset/2018_02_15/o1_mf_nnndf_TAG20180215T052016_f89lst35_.bkp tag=TAG20180215T052016
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 15-FEB-18

RMAN> recover datafile 1 until sequence 66;

Starting recover at 15-FEB-18
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 63 is already on disk as file /u01/app/oracle/fast_recovery_area/DUCAT/archivelog/2018_02_15/o1_mf_1_63_f89m3dbb_.arc
archived log for thread 1 with sequence 64 is already on disk as file /u01/app/oracle/fast_recovery_area/DUCAT/archivelog/2018_02_15/o1_mf_1_64_f89m51w3_.arc
archived log for thread 1 with sequence 65 is already on disk as file /u01/app/oracle/fast_recovery_area/DUCAT/archivelog/2018_02_15/o1_mf_1_65_f89m55fr_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/DUCAT/archivelog/2018_02_15/o1_mf_1_63_f89m3dbb_.arc thread=1 sequence=63
media recovery complete, elapsed time: 00:00:01
Finished recover at 15-FEB-18

RMAN>



SQL>  select hxfil FILENUMBER, fhsta STATUS, fhscn SCN, fhrba_seq SEQUENCE from x$kcvfh;

FILENUMBER     STATUS SCN                SEQUENCE
---------- ---------- ---------------- ----------
         1       8192 2139749                  66
         2          0 2139751                  66
         3          0 2139751                  66
         4          0 2139751                  66
         5          0 2139751                  66
         7          0 2139751                  66

6 rows selected.

SQL> alter database open;

Database altered.


SQL>

No comments:

Post a Comment