資料庫所有檔案丟失後透過RMAN實現恢復

shuyingxi發表於2013-03-30

 

a. 執行資料庫的完全備份,包含所有控制檔案、日誌檔案、資料檔案

[oracle@ora10g ~]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Mar 30 16:12:44 2013

 

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

 

connected to target database: ORCL (DBID=1321883643)

 

備份資料庫

 

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> backup database plus archivelog;

 

 

Starting backup at 30-MAR-13

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=38 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=20 RECID=1 STAMP=796651137

input archived log thread=1 sequence=21 RECID=2 STAMP=796653229

input archived log thread=1 sequence=22 RECID=3 STAMP=811432370

input archived log thread=1 sequence=24 RECID=6 STAMP=811440733

input archived log thread=1 sequence=25 RECID=4 STAMP=811440733

input archived log thread=1 sequence=26 RECID=5 STAMP=811440733

channel ORA_DISK_1: starting piece 1 at 30-MAR-13

channel ORA_DISK_1: finished piece 1 at 30-MAR-13

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_annnn_TAG20130330T161348_8of7owoq_.bkp tag=TAG20130330T161348 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=1 RECID=7 STAMP=811440827

channel ORA_DISK_1: starting piece 1 at 30-MAR-13

channel ORA_DISK_1: finished piece 1 at 30-MAR-13

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_annnn_TAG20130330T161348_8of7ozxh_.bkp tag=TAG20130330T161348 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 30-MAR-13

 

Starting backup at 30-MAR-13

using channel ORA_DISK_1

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/orcl/system01.dbf

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

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

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

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

channel ORA_DISK_1: starting piece 1 at 30-MAR-13

channel ORA_DISK_1: finished piece 1 at 30-MAR-13

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_nnndf_TAG20130330T161353_8of7p2qg_.bkp tag=TAG20130330T161353 comment=NONE

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

Finished backup at 30-MAR-13

 

Starting backup at 30-MAR-13

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=2 RECID=8 STAMP=811441081

channel ORA_DISK_1: starting piece 1 at 30-MAR-13

channel ORA_DISK_1: finished piece 1 at 30-MAR-13

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_annnn_TAG20130330T161802_8of7xv8q_.bkp tag=TAG20130330T161802 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 30-MAR-13

 

Starting Control File and SPFILE Autobackup at 30-MAR-13

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 30-MAR-13

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

2       229.50K    DISK        00:00:00     30-MAR-13

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130330T161348

        Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_annnn_TAG20130330T161348_8of7ozxh_.bkp

 

  List of Archived Logs in backup set 2

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    1       1006386    30-MAR-13 1006669    30-MAR-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    1.15G      DISK        00:03:55     30-MAR-13

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20130330T161353

        Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_nnndf_TAG20130330T161353_8of7p2qg_.bkp

  List of Datafiles in backup set 3

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 1006678    30-MAR-13 /u01/app/oracle/oradata/orcl/system01.dbf

  2       Full 1006678    30-MAR-13 /u01/app/oracle/oradata/orcl/sysaux01.dbf

  3       Full 1006678    30-MAR-13 /u01/app/oracle/oradata/orcl/undotbs01.dbf

  4       Full 1006678    30-MAR-13 /u01/app/oracle/oradata/orcl/users01.dbf

  5       Full 1006678    30-MAR-13 /u01/app/oracle/oradata/orcl/example01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

4       19.50K     DISK        00:00:01     30-MAR-13

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20130330T161802

        Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_annnn_TAG20130330T161802_8of7xv8q_.bkp

 

  List of Archived Logs in backup set 4

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

  ---- ------- ---------- --------- ---------- ---------

  1    2       1006669    30-MAR-13 1006787    30-MAR-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

5       Full    9.36M      DISK        00:00:10     30-MAR-13

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20130330T161806

        Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp

  SPFILE Included: Modification time: 30-MAR-13

  SPFILE db_unique_name: ORCL

Control File Included: Ckp SCN: 1006799      Ckp time: 30-MAR-13

 

 

b.  刪除控制檔案、引數檔案、資料檔案

SQL> select file_name from dba_data_files;

 

FILE_NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/orcl/users01.dbf

/u01/app/oracle/oradata/orcl/undotbs01.dbf

/u01/app/oracle/oradata/orcl/sysaux01.dbf

/u01/app/oracle/oradata/orcl/system01.dbf

/u01/app/oracle/oradata/orcl/example01.dbf

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/users01.dbf

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/undotbs01.dbf

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/sysaux01.dbf

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/system01.dbf

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/example01.dbf

 

SQL> select name from v$controlfile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/orcl/control01.ctl

/u01/app/oracle/flash_recovery_area/orcl/control02.ctl

 

SQL> !rm -rf /u01/app/oracle/oradata/orcl/control01.ctl

 

SQL> !rm -rf /u01/app/oracle/flash_recovery_area/orcl/control02.ctl

 

SQL> !ls -l /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora

-rw-r----- 1 oracle oinstall 3584 Mar 30 16:20 /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora

 

SQL> !rm /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora

 

SQL> !ls -l /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora

ls: /u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.ora: No such file or directory

 

 

關閉資料庫

SQL> shutdown abort

ORACLE instance shut down.

SQL> startup

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'

SQL>

 

 

c. 啟動例項,恢復引數檔案

Rman還是可以啟動例項

 

RMAN> startup

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'

 

starting Oracle instance without parameter file for retrieval of spfile

 

 

Oracle instance started

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

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

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

RMAN-03002: failure of startup command at 03/30/2013 16:25:09

ORA-00205: error in identifying control file, check alert log for more info

 

 

RMAN> restore spfile from autobackup;

 

Starting restore at 30-MAR-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=20 device type=DISK

 

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

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

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

RMAN-03002: failure of restore command at 03/30/2013 16:26:11

RMAN-06495: must explicitly specify DBID with SET DBID command

 

RMAN> restore spfile from autobackup db_name='orcl';

 

Starting restore at 30-MAR-13

using channel ORA_DISK_1

 

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

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

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

RMAN-03002: failure of restore command at 03/30/2013 16:26:58

RMAN-06495: must explicitly specify DBID with SET DBID command

 

RMAN> restore spfile from autobackup recovery area='/u01/app/oracle/flash_recovery_area' db_name='orcl';

 

Starting restore at 30-MAR-13

using channel ORA_DISK_1

 

recovery area destination: /u01/app/oracle/flash_recovery_area

database name (or database unique name) used for search: ORCL

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 30-MAR-13

 

d. 重啟資料庫例項,恢復控制檔案,並裝載資料庫

恢復完引數檔案之後需要重啟一下例項。

RMAN> shutdown immediate

 

RMAN> startup

 

 

恢復控制檔案

RMAN> restore controlfile from  autobackup recovery area='/u01/app/oracle/flash_recovery_area' db_name='orcl';

 

Starting restore at 30-MAR-13

using channel ORA_DISK_1

 

recovery area destination: /u01/app/oracle/flash_recovery_area

database name (or database unique name) used for search: ORCL

channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp

channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/cntrlorcl.dbf

Finished restore at 30-MAR-13

 

掛載資料庫

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

還原資料庫

 

RMAN> restore database;

 

Starting restore at 30-MAR-13

Starting implicit crosscheck backup at 30-MAR-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=22 device type=DISK

Crosschecked 4 objects

Finished implicit crosscheck backup at 30-MAR-13

 

Starting implicit crosscheck copy at 30-MAR-13

using channel ORA_DISK_1

Finished implicit crosscheck copy at 30-MAR-13

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_03_30/o1_mf_s_811441086_8of7y75l_.bkp

 

using channel ORA_DISK_1

 

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/orcl/system01.dbf

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

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

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

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

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_nnndf_TAG20130330T161353_8of7p2qg_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_30/o1_mf_nnndf_TAG20130330T161353_8of7p2qg_.bkp tag=TAG20130330T161353

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:02:52

Finished restore at 30-MAR-13

 

f. 恢復,開啟資料庫

 

RMAN> recover database;

 

RMAN> Alter database open resetlogs;

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

相關文章