RMAN恢复案例之五

丢失控制文件,数据文件和spfile,但是联机日志文件没丢

 

具体的操作步骤如下:
RMAN> startup nomount;
RMAN>restore spfile from '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp';
RMAN> shutdown abort;
RMAN> startup nomount;
RMAN>restore controlfile from '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp';
RMAN> sql 'alter database mount';
RMAN> restore database;
RMAN> recover database;
RMAN> sql 'alter database open resetlogs';


具体实验步骤如下:
先模拟丢失控制文件,数据文件和spfile数据:
[oracle@even oradata]$ cd test/
[oracle@even test]$ ll
total 2314676
-rw-r----- 1 oracle oinstall    7356416 Dec 28 14:43 control01.ctl
-rw-r----- 1 oracle oinstall    7356416 Dec 28 14:43 control02.ctl
-rw-r----- 1 oracle oinstall    7356416 Dec 28 14:43 control03.ctl
-rw-r----- 1 oracle oinstall  104865792 Dec 28 14:28 example01.dbf
-rw-r----- 1 oracle oinstall   52429312 Dec 28 14:22 redo01.log
-rw-r----- 1 oracle oinstall   52429312 Dec 28 14:19 redo02.log
-rw-r----- 1 oracle oinstall   52429312 Dec 28 14:21 redo03.log
-rw-r----- 1 oracle oinstall  251666432 Dec 28 14:28 sysaux01.dbf
-rw-r----- 1 oracle oinstall  503324672 Dec 28 14:28 system01.dbf
-rw-r----- 1 oracle oinstall   20979712 Dec 28 11:57 temp01.dbf
-rw-r----- 1 oracle oinstall   94380032 Dec 28 14:28 undotbs01.dbf
-rw-r----- 1 oracle oinstall 1216356352 Dec 28 14:28 users01.dbf
[oracle@even test]$ rm -rf control01.ctl control02.ctl control03.ctl users01.dbf
[oracle@even test]$ ll
total 1104076
-rw-r----- 1 oracle oinstall 104865792 Dec 28 14:28 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 Dec 28 14:22 redo01.log
-rw-r----- 1 oracle oinstall  52429312 Dec 28 14:19 redo02.log
-rw-r----- 1 oracle oinstall  52429312 Dec 28 14:21 redo03.log
-rw-r----- 1 oracle oinstall 251666432 Dec 28 14:28 sysaux01.dbf
-rw-r----- 1 oracle oinstall 503324672 Dec 28 14:28 system01.dbf
-rw-r----- 1 oracle oinstall  20979712 Dec 28 11:57 temp01.dbf
-rw-r----- 1 oracle oinstall  94380032 Dec 28 14:28 undotbs01.dbf
[oracle@even test]$ cd $ORACLE_HOME/dbs
[oracle@even dbs]$ ll
total 7276
-rw-r--r-- 1 oracle oinstall    1230 Dec 13 15:04 createDB.sql
-rw-rw---- 1 oracle oinstall    1544 Dec 28 11:55 hc_test.dat
-rwxr--r-- 1 oracle oinstall      82 Dec 13 08:16 HelloWorld.sh
-rw-r----- 1 oracle oinstall   12920 May  3  2001 initdw.ora
-rw-r----- 1 oracle oinstall    8385 Sep 11  1998 init.ora
-rw-rw---- 1 oracle oinstall      24 Dec 28 11:05 lkDUMMY
-rw-rw---- 1 oracle oinstall      24 Dec 28 11:55 lkTEST
-rw-r----- 1 oracle oinstall    1536 Dec 28 12:05 orapwtest
-rwxr-xr-x 1 oracle oinstall    3231 Dec 13 06:42 rman_incremental_backup.sh
-rw-rw-rw- 1 oracle oinstall   12971 Dec 13 08:25 rman_incremental_backup.sh.out
-rw-r----- 1 oracle oinstall 7356416 Dec 28 14:12 snapcf_test.f
-rw-r----- 1 oracle oinstall    3584 Dec 28 14:25 spfiletest.ora
-rw-r--r-- 1 oracle oinstall     748 Dec 10 12:31 sqlnet.log
[oracle@even dbs]$ rm -rf spfiletest.ora

 

通过RMAN做还原恢复处理
[oracle@even 2012_12_28]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 28 14:22:08 2012

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

connected to target database: TEST (DBID=2101363784)


RMAN> SHUTDOWN IMMEDIATE

database dismounted
Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/inittest.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     1218268 bytes
Variable Size                 54528292 bytes
Database Buffers             100663296 bytes
Redo Buffers                   2973696 bytes

RMAN> restore spfile from '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp';

Starting restore at 28-DEC-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=35 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=34 devtype=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: sid=33 devtype=DISK

channel ORA_DISK_2: skipped, autobackup already found
channel ORA_DISK_3: skipped, autobackup already found
channel ORA_DISK_4: skipped, autobackup already found
channel ORA_DISK_1: autobackup found: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 28-DEC-12

RMAN> shutdown abort;

Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)
Oracle instance started

Total System Global Area     285212672 bytes

Fixed Size                     1218992 bytes
Variable Size                 71304784 bytes
Database Buffers             209715200 bytes
Redo Buffers                   2973696 bytes

RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp';

Starting restore at 28-DEC-12

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=155 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=154 devtype=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: sid=153 devtype=DISK

channel ORA_DISK_2: skipped, autobackup already found
channel ORA_DISK_3: skipped, autobackup already found
channel ORA_DISK_4: skipped, autobackup already found
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:10
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 28-DEC-12

RMAN>
RMAN>
RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4

RMAN> restore database;

Starting restore at 28-DEC-12
Starting implicit crosscheck backup at 28-DEC-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
Crosschecked 9 objects
Finished implicit crosscheck backup at 28-DEC-12

Starting implicit crosscheck copy at 28-DEC-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 28-DEC-12

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2012_12_28/o1_mf_s_803225528_8ftg1sn4_.bkp
File Name: /u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_28/o1_mf_1_52_8ftgmlqp_.arc

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/test/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/test/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/test/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/test/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/test/example01.dbf
channel ORA_DISK_1: reading from backup piece

/u01/app/oracle/flash_recovery_area/TEST/backupset/2012_12_28/o1_mf_nnndf_TAG20121228T140859_8ftfvwkd_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/TEST/backupset/2012_12_28/o1_mf_nnndf_TAG20121228T140859_8ftfvwkd_.bkp tag=TAG20121228T140859
channel ORA_DISK_1: restore complete, elapsed time: 00:01:36
Finished restore at 28-DEC-12

RMAN> recover database;

Starting recover at 28-DEC-12
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 51 is already on disk as file /u01/app/oracle/oradata/test/redo02.log
archive log thread 1 sequence 52 is already on disk as file /u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_28/o1_mf_1_52_8ftgmlqp_.arc
archive log thread 1 sequence 53 is already on disk as file /u01/app/oracle/oradata/test/redo01.log
archive log filename=/u01/app/oracle/oradata/test/redo02.log thread=1 sequence=51
archive log filename=/u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_28/o1_mf_1_52_8ftgmlqp_.arc thread=1 sequence=52
archive log filename=/u01/app/oracle/oradata/test/redo01.log thread=1 sequence=53
media recovery complete, elapsed time: 00:00:03
Finished recover at 28-DEC-12

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

注意:如果是通过alter database open resetlogs 打开数据的,一定最好是做个数据库的全备。

你可能感兴趣的:(RMAN恢复案例之五)