RMAN恢復 執行不重要檔案的RMAN恢復

liuzhen_basis發表於2014-08-07

對於資料庫而言,如果丟失資料檔案不在system和undo表空間,就視為不重要資料檔案

前提:已經使用RMAN備份過資料庫

步驟:

1、如果資料檔案處於開啟狀態,就使表空間offline

2、restore

3、recover 

4、online

 

檢視當前所有資料檔案

SQL> select name from v$datafile;

NAME

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

/home/oracle/app/oracle/oradata/sap/system01.dbf

/home/oracle/app/oracle/oradata/sap/sysaux01.dbf

/home/oracle/app/oracle/oradata/sap/undotbs01.dbf

/home/oracle/app/oracle/oradata/sap/users01.dbf

/home/oracle/app/oracle/oradata/sap/example01.dbf

/home/oracle/app/oracle/oradata/sap/lztest.dbf

6 rows selected.

 

 

資料庫執行中強制刪除資料檔案/home/oracle/app/oracle/oradata/sap/users01.dbf

 

rm /home/oracle/app/oracle/oradata/sap/users01.dbf

 

 

SQL> shutdown

ORA-01116: error in opening database file 4

ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/sap/users01.dbf'

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

 

 

SQL> alter tablespace users offline immediate;

Tablespace altered.

 

RMAN> restore tablespace users;

Starting restore at 03-MAR-14

starting full resync of recovery catalog

full resync complete

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=192 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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 1 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950wdb_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950wdb_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 2 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950xhw_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950xhw_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 2

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 3 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950yoo_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950yoo_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 3

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 03-MAR-14

RMAN> recover tablespace users;

Starting recover at 03-MAR-14

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 13 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_13_9kbhlkwh_.arc

archived log for thread 1 with sequence 14 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_14_9kbhm25o_.arc

archived log for thread 1 with sequence 15 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_15_9kbhmfx5_.arc

archived log for thread 1 with sequence 16 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_16_9kbhmsw5_.arc

archived log for thread 1 with sequence 17 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_17_9kbhn87m_.arc

archived log for thread 1 with sequence 18 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_18_9kbhtkfl_.arc

archived log for thread 1 with sequence 19 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_19_9kbhvogj_.arc

archived log for thread 1 with sequence 20 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_20_9kbhwctk_.arc

archived log for thread 1 with sequence 21 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_21_9kbhxcrg_.arc

archived log for thread 1 with sequence 22 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_22_9kbhy5nw_.arc

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_13_9kbhlkwh_.arc thread=1 sequence=13

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_14_9kbhm25o_.arc thread=1 sequence=14

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_15_9kbhmfx5_.arc thread=1 sequence=15

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_16_9kbhmsw5_.arc thread=1 sequence=16

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_17_9kbhn87m_.arc thread=1 sequence=17

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_18_9kbhtkfl_.arc thread=1 sequence=18

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_19_9kbhvogj_.arc thread=1 sequence=19

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_20_9kbhwctk_.arc thread=1 sequence=20

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

Finished recover at 03-MAR-14

 

 

RMAN> sql 'alter tablespace users online';

sql statement: alter tablespace users online

 

 

 

在資料庫關閉狀態刪除 users檔案

 

[root@sap trace]# mv /home/oracle/app/oracle/oradata/sap/users01.dbf /home/oracle/app/oracle/oradata/sap/users01.dbf_del

 

 

啟動資料庫,報錯

SQL> startup

ORACLE instance started.

Total System Global Area 830930944 bytes

Fixed Size                 2217912 bytes

Variable Size                 503318600 bytes

Database Buffers         318767104 bytes

Redo Buffers                 6627328 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 4 - see DBWR trace file

ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/sap/users01.dbf'

[oracle@sap ~]$ rman target / catalog rman/rman@catalog:1521/catalog

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 3 20:35:13 2014

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

connected to target database: SAP (DBID=3375191994, not open)

connected to recovery catalog database

RMAN>

 

恢復表空間

RMAN> restore tablespace users;

Starting restore at 03-MAR-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=129 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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 1 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950wdb_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950wdb_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 2 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950xhw_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950xhw_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 2

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

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 00004 to /home/oracle/app/oracle/oradata/sap/users01.dbf

channel ORA_DISK_1: restoring section 3 of 3

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950yoo_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnndf_TAG20140303T063924_9k950yoo_.bkp tag=TAG20140303T063924

channel ORA_DISK_1: restored backup piece 3

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 03-MAR-14

 

 

RMAN> recover tablespace users;

Starting recover at 03-MAR-14

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 13 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_13_9kbhlkwh_.arc

archived log for thread 1 with sequence 14 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_14_9kbhm25o_.arc

archived log for thread 1 with sequence 15 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_15_9kbhmfx5_.arc

archived log for thread 1 with sequence 16 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_16_9kbhmsw5_.arc

archived log for thread 1 with sequence 17 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_17_9kbhn87m_.arc

archived log for thread 1 with sequence 18 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_18_9kbhtkfl_.arc

archived log for thread 1 with sequence 19 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_19_9kbhvogj_.arc

archived log for thread 1 with sequence 20 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_20_9kbhwctk_.arc

archived log for thread 1 with sequence 21 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_21_9kbhxcrg_.arc

archived log for thread 1 with sequence 22 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_22_9kbhy5nw_.arc

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_13_9kbhlkwh_.arc thread=1 sequence=13

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_14_9kbhm25o_.arc thread=1 sequence=14

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_15_9kbhmfx5_.arc thread=1 sequence=15

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_16_9kbhmsw5_.arc thread=1 sequence=16

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_17_9kbhn87m_.arc thread=1 sequence=17

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_18_9kbhtkfl_.arc thread=1 sequence=18

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_19_9kbhvogj_.arc thread=1 sequence=19

archived log file name=/home/oracle/app/oracle/flash_recovery_area/SAP/archivelog/2014_03_03/o1_mf_1_20_9kbhwctk_.arc thread=1 sequence=20

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

Finished recover at 03-MAR-14

 

 

SQL> alter database open;

Database altered.

 

 

恢復完成

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

相關文章