非歸檔模式恢復資料庫

skyin_1603發表於2016-11-21

在非歸檔模式下,丟失任意的資料檔案並恢復資料庫。以下是測試的過程:

---檢視資料庫的歸檔模式

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]$

#所有的資料檔案恢復成功。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2128825/,如需轉載,請註明出處,否則將追究法律責任。

相關文章