快速镜像恢复

版权声明:欢迎指正,评论,共同学习 https://blog.csdn.net/m18994118189/article/details/82796137

1.使用rman,对users表空间,做镜像备份
backup as copy tablespace users;

2.在数据库中,查询users表空间所对应的数据文件
select TABLESPACE_NAME,FILE_NAME from dba_data_files where TABLESPACE_NAME='USERS';

TABLESPACE_NAME                FILE_NAME
------------------------------ --------------------------------------------------
USERS                          /u01/app/oracle/oradata/orcl/users01.dbf

删除,模拟故障
SQL> !rm -rf /u01/app/oracle/oradata/orcl/users01.dbf

ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'

使该文件offline,准备恢复
alter database datafile 4 offline;


3.在rman中,使用快速镜像恢复
RMAN> switch datafile 4 to copy;

using target database control file instead of recovery catalog
datafile 4 switched to datafile copy "/u02/ORCL/datafile/o1_mf_users_cnbqw6f6_.dbf"

RMAN> recover datafile 4;

Starting recover at 25-MAY-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK

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

扫描二维码关注公众号,回复: 3417517 查看本文章

Finished recover at 25-MAY-16

4.数据库中使该文件online
alter database datafile 4 online;

5.在数据库查看当前所有的数据文件
SQL> select name from v$datafile;

NAME
-------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u02/ORCL/datafile/o1_mf_users_cnbqw6f6_.dbf
/u01/app/oracle/oradata/orcl/example01.dbf

发现users表空间,实际使用的数据文件,变成了,我们之前做的镜像备份文件
如果看着别扭,想变成原来的样子
再来一次镜像备份与快速镜像恢复

6.在rman中,使用镜像备份,指定备份的位置是该数据文件被删除之前的位置及文件名
RMAN> backup as copy datafile 4 format '/u01/app/oracle/oradata/orcl/users01.dbf';

Starting backup at 25-MAY-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u02/ORCL/datafile/o1_mf_users_cnbqw6f6_.dbf
output file name=/u01/app/oracle/oradata/orcl/users01.dbf tag=TAG20160525T162240 RECID=8 STAMP=912788561
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 25-MAY-16

Starting Control File and SPFILE Autobackup at 25-MAY-16
piece handle=/u02/ORCL/autobackup/2016_05_25/o1_mf_s_912788561_cnbr6kx1_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 25-MAY-16

7.在数据库中,offline datafile 4
SQL> alter database datafile 4 offline;

Database altered.

8.在rman中,执行快速镜像恢复
RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "/u01/app/oracle/oradata/orcl/users01.dbf"

RMAN> recover datafile 4;

Starting recover at 25-MAY-16
using channel ORA_DISK_1

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

Finished recover at 25-MAY-16

9.在数据库,Online datafile 4
SQL> alter database datafile 4 online;

Database altered.

再次查询数据文件,发现变回原来的文件名了
SQL> select name from v$datafile;

NAME
---------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf

猜你喜欢

转载自blog.csdn.net/m18994118189/article/details/82796137