rman恢复 使用switch映像副本进行恢复

发起映像副本备份

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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27771627/viewspace-1247222/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值