ITPub博客

首页 > 数据库 > Oracle > Backup And Recovery User's Guide-从RMAN开始-恢复表空间

Backup And Recovery User's Guide-从RMAN开始-恢复表空间

原创 Oracle 作者:luisedalian 时间:2014-02-14 08:31:14 0 删除 编辑

可以在数据库打开时在单独的表空间上使用RESTORE TABLESPACERECOVER TABLESPACE命令。

此时,必须使需要恢复的表空间脱机,还原和恢复表空间,然后再使表空间联机。

如果不能还原数据文件到新的位置,则使用RMANSET NEWNAME命令来指定新的文件名。

然后使用SWITCH DATAFILE ALL命令,等价于使用ALTER DATABASE RENAME FILE这个SQL命令来更新控制文件反映新的文件名。

与用户管理的介质恢复不同,不能将联机表空间置于备份模式中。

与用户管理的工具不同,RMAN不需要额外的日志或备份模式,因为它知道数据块的格式。

练习:在数据库打开时,恢复单个的表空间

# 1. 对数据库进行备份

RMAN> backup database;

Starting backup at 12-JUL-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/TestDB12/system01.dbf

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

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

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

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

channel ORA_DISK_1: starting piece 1 at 12-JUL-13

channel ORA_DISK_1: finished piece 1 at 12-JUL-13

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB12/backupset/2013_07_12/o1_mf_nnndf_TAG20130712T054632_8xzn3rgk_.bkp tag=TAG20130712T054632 comment=NONE

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

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 12-JUL-13

channel ORA_DISK_1: finished piece 1 at 12-JUL-13

piece handle=/u01/app/oracle/fast_recovery_area/TESTDB12/backupset/2013_07_12/o1_mf_ncsnf_TAG20130712T054632_8xzn5jod_.bkp tag=TAG20130712T054632 comment=NONE

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

Finished backup at 12-JUL-13

# 2. 删除users表空间中emp表中的所有数据

sys@TESTDB12>delete  from scott.emp;

14 rows deleted.

# 3. 使表空间脱机

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';

sql statement: ALTER TABLESPACE users OFFLINE

# 4. 还原和恢复表空间(为数据文件指定了新的名字)

RMAN> RUN

2> {

3>   SET NEWNAME FOR DATAFILE '/u01/app/oracle/oradata/TestDB12/users01.dbf'

4>    TO '/u01/app/oracle/oradata/TestDB12/users001.dbf';

5>   RESTORE TABLESPACE users;

6>   SWITCH DATAFILE ALL;  

7>   RECOVER TABLESPACE users;

8> }

executing command: SET NEWNAME

Starting restore at 12-JUL-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=20 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 /u01/app/oracle/oradata/TestDB12/users001.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TESTDB12/backupset/2013_07_12/o1_mf_nnndf_TAG20130712T054632_8xzn3rgk_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TESTDB12/backupset/2013_07_12/o1_mf_nnndf_TAG20130712T054632_8xzn3rgk_.bkp tag=TAG20130712T054632

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 12-JUL-13

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=820561942 file name=/u01/app/oracle/oradata/TestDB12/users001.dbf

Starting recover at 12-JUL-13

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 12-JUL-13

# 4. 使表空间联机

MAN> sql 'alter tablespace users online';

sql statement: alter tablespace users online

# 5. 查看表空间的内容,数据已经被删除了,说明已经恢了备份之后的操作。

 

可以使用RESTORE DATAFILERECOVER DATAFILE命令在数据文件层次进行恢复。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17013648/viewspace-1081159/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    5642431