非归档模式恢复数据库

在非归档模式下,丢失任意的数据文件并恢复数据库。以下是测试的过程:

---查看数据库的归档模式:

PROD>archive log list;

Database log mode              No Archive Mode

Automatic archival            Disabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence    1

Current log sequence          3

PROD>

 
---进入rman进行全库备份:

[Oracle@enmo ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 21 23:09:20 2016

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

connected to target database: PROD (DBID=338469376, not open) 

RMAN>

---进行全库备份:

RMAN> backup database;

 

Starting backup at 21-NOV-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/myspace_01.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/PROD/ts_xxf_01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/PROD/ts_ctl01.dbf

channel ORA_DISK_1: starting piece 1 at 21-NOV-16

channel ORA_DISK_1: finished piece 1 at 21-NOV-16

piece handle=/u01/app/backup/db_0lrlgn84_1_1.rmn tag=TAG20161121T231100 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:04:50

Finished backup at 21-NOV-16

 

Starting Control File and SPFILE Autobackup at 21-NOV-16

piece handle=/u01/app/FRA/PROD/autobackup/2016_11_21/o1_mf_s_928537336_d363x905_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 21-NOV-16

---打开数据库:


PROD>alter database open;

Database altered.

 

---删除所有数据文件:
 

[oracle@enmo ~]$ cd  /u01/app/oracle/oradata/PROD/

[oracle@enmo PROD]$ ls

control01.ctl  redo01.log  redo03b.log  system01.dbf  temp04.dbf    undotbs01.dbf

example01.dbf  redo02b.log  redo03.log    temp01.dbf    ts_ctl01.dbf  users01.dbf

redo01b.log    redo02.log  sysaux01.dbf  temp03.dbf    ts_xxf_01.dbf

[oracle@enmo PROD]$ 

[oracle@enmo PROD]$ 

[oracle@enmo PROD]$ rm *.dbf

[oracle@enmo PROD]$ ls *.dbf

ls: *.dbf: No such file or directory

 #已经删除所有数据文件。

---使用rman进行恢复数据库:


[oracle@enmo ~]$ rman target / 

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 21 23:23:58 2016

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

connected to target database: PROD (DBID=338469376, not open) 

RMAN> 

 
--重载数据库:

RMAN> restore database;

 

Starting restore at 21-NOV-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=17 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/PROD/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD/example01.dbf

channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD/ts_xxf_01.dbf

channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD/ts_ctl01.dbf

channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/myspace_01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/backup/db_0lrlgn84_1_1.rmn

channel ORA_DISK_1: piece handle=/u01/app/backup/db_0lrlgn84_1_1.rmn tag=TAG20161121T231100

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:05:14

Finished restore at 21-NOV-16

 
--通过介质恢复数据库:

RMAN> recover database;

 

Starting recover at 21-NOV-16

using channel ORA_DISK_1

starting media recovery

 

archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/oradata/PROD/redo03.log

archived log file name=/u01/app/oracle/oradata/PROD/redo03.log thread=1 sequence=3

media recovery complete, elapsed time: 00:00:02

Finished recover at 21-NOV-16

 
---尝试打开数据库:
RMAN> alter database open;

 

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of alter db command at 11/21/2016 23:30:18

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 
---以RESETLOGS方式打开数据库:

RMAN> alter database open RESETLOGS;

database opened

 

---恢复之后查看数据文件:

[oracle@enmo PROD]$ ls *.dbf

example01.dbf  system01.dbf  temp03.dbf  ts_ctl01.dbf  undotbs01.dbf

sysaux01.dbf  temp01.dbf    temp04.dbf  ts_xxf_01.dbf  users01.dbf

[oracle@enmo PROD]$ 

#所有的数据文件恢复成功。

相关推荐