rman恢復 使用switch映像副本進行恢復

liuzhen_basis發表於2014-08-07

發起映像副本備份

RMAN> backup as copy database;

Starting backup at 03-MAR-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=135 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001 name=/home/oracle/app/oracle/oradata/sap/system01.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_system_9kbsnloo_.dbf tag=TAG20140303T213722 RECID=14 STAMP=841268277

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002 name=/home/oracle/app/oracle/oradata/sap/sysaux01.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_sysaux_9kbsop61_.dbf tag=TAG20140303T213722 RECID=15 STAMP=841268299

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003 name=/home/oracle/app/oracle/oradata/sap/undotbs01.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_undotbs1_9kbsphov_.dbf tag=TAG20140303T213722 RECID=16 STAMP=841268312

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=/home/oracle/app/oracle/oradata/sap/example01.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_example_9kbspz1g_.dbf tag=TAG20140303T213722 RECID=17 STAMP=841268322

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07

channel ORA_DISK_1: starting datafile copy

input datafile file number=00006 name=/home/oracle/app/oracle/oradata/sap/lztest.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_lztest_9kbsq6cy_.dbf tag=TAG20140303T213722 RECID=18 STAMP=841268326

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile copy

copying current control file

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/controlfile/o1_mf_TAG20140303T213722_9kbsq7n2_.ctl tag=TAG20140303T213722 RECID=19 STAMP=841268328

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004 name=/home/oracle/app/oracle/oradata/sap/users01.dbf

output file name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_users_9kbsq8qb_.dbf tag=TAG20140303T213722 RECID=20 STAMP=841268328

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 03-MAR-14

channel ORA_DISK_1: finished piece 1 at 03-MAR-14

piece handle=/home/oracle/app/oracle/flash_recovery_area/SAP/backupset/2014_03_03/o1_mf_nnsnf_TAG20140303T213722_9kbsqb2j_.bkp tag=TAG20140303T213722 comment=NONE

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

Finished backup at 03-MAR-14

 

 

刪掉一個檔案

root@sap ~]# rm /home/oracle/app/oracle/oradata/sap/users01.dbf

 

重啟顯示失敗

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

SQL>

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'

 

 

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_users_9kbsq8qb_.dbf"

starting full resync of recovery catalog

full resync complete

 

 

RMAN> recover datafile 4;

Starting recover at 03-MAR-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=129 device type=DISK

starting media recovery

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

Finished recover at 03-MAR-14

 

 

SQL> alter database open;

Database altered.

 

 

檢視,目前資料檔案已經switch到的FRA目錄下

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/flash_recovery_area/SAP/datafile/o1_mf_users_9kbsq8qb_.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

 

 

RMAN> backup as copy datafile 4

2> format '/home/oracle/app/oracle/oradata/sap/users01.dbf';

Starting backup at 03-MAR-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004 name=/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_users_9kbsq8qb_.dbf

output file name=/home/oracle/app/oracle/oradata/sap/users01.dbf tag=TAG20140303T220445 RECID=21 STAMP=841269885

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 03-MAR-14

 

SQL> select df.name,ts#,ts.name

2 from v$datafile df join v$tablespace ts

3 using (ts#);

NAME

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

TS# NAME

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

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

0 SYSTEM

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

1 SYSAUX

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

2 UNDOTBS1

NAME

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

TS# NAME

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

/home/oracle/app/oracle/flash_recovery_area/SAP/datafile/o1_mf_users_9kbsq8qb_.d

bf

4 USERS

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

6 EXAMPLE

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

7 LZTEST

NAME

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

TS# NAME

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

6 rows selected.

 

 

SQL> alter tablespace users offline immediate;

Tablespace altered.

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "/home/oracle/app/oracle/oradata/sap/users01.dbf"

starting full resync of recovery catalog

full resync complete

RMAN> recover datafile 4;

Starting recover at 03-MAR-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=129 device type=DISK

starting media recovery

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

Finished recover at 03-MAR-14

 

 

SQL> alter tablespace users online;

Tablespace altered.

 

 

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.

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

相關文章