RMAN恢复案例之一

非系统表空间和undo表空间丢失的恢复

以下的例子是模拟users表空间丢失后如何通过RMAN进行恢复,其他的非系统表空间的丢失同理处理即可,前提是数据库是归档模式,而且备份文件完整有效。顺便介绍下如何开归档模式:

shutdown immediate
startup mount
alter database archivelog;
alter database open;


[oracle@even test]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 27 14:04:35 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@even test]$ rm -rf users01.dbf

SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/u01/app/oracle/oradata/test/users01.dbf'

[oracle@even ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Dec 27 14:09:09 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TEST (DBID=2100083002, not open)

RMAN> restore tablespace users;

Starting restore at 27-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=154 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=153 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/test/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/TEST/backupset/2012_12_27/o1_mf_nnndf_TAG20121227T133532_8fqqkdcs_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/TEST/backupset/2012_12_27/o1_mf_nnndf_TAG20121227T133532_8fqqkdcs_.bkp tag=TAG20121227T133532
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 27-DEC-12


RMAN> recover tablespace users;

Starting recover at 27-DEC-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

starting media recovery

archive log thread 1 sequence 16 is already on disk as file /u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_27/o1_mf_1_16_8fqqo5hf_.arc
archive log thread 1 sequence 17 is already on disk as file /u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_27/o1_mf_1_17_8fqrs24p_.arc
archive log thread 1 sequence 18 is already on disk as file /u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_27/o1_mf_1_18_8fqryd16_.arc
archive log filename=/u01/app/oracle/flash_recovery_area/TEST/archivelog/2012_12_27/o1_mf_1_16_8fqqo5hf_.arc thread=1 sequence=16
media recovery complete, elapsed time: 00:00:00
Finished recover at 27-DEC-12


RMAN> sql 'alter database open';

sql statement: alter database open

RMAN> sql 'alter tablespace users online';

sql statement: alter tablespace users online

重新HR登陆,查询下users表空间的employees表
SQL> conn hr/hr
Connected.
SQL> select count(*) from employees;

  COUNT(*)
----------
       107

上面的信息表示表空间恢复成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值