RMAN不完全恢复方法(恢复到数据库某一时间点)

RMAN不完全恢复方法

试验目的:利用RMAN完成对数据库的不完全恢复(将数据库恢复到某个时间点)
试验步骤:
        1. RMAN备份数据库:backup database;  

2. 记录当前时间:
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2018-05-09 15:37:15

3.删除一个表:

drop table emp purge;

4.如果在删除前没有做时间的记录,可以通过日志挖掘来找出删除的时间或scn:

SQL> exec dbms_logmnr.add_logfile('/home/oracle/app/oracle/oradata/orcl/redo01.log');    (这里的日志如果是归档日志,也可用同样的方法添加进去)

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);

PL/SQL procedure successfully completed.

SQL> select scn,to_char(timestamp,'yyyy-mm-dd hh24:mi:ss') time,sql_redo from v$logmnr_contents where table_name='EMP';

       SCN                                TIME                                           SQL_REDO

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

   1201958                  2018-05-09 15:37:26                  drop table emp purge;


SQL> exec dbms_logmnr.end_logmnr;


5.通过RMAN来恢复到指定时间点

             RMAN> shutdown immediate

             RMAN> startup mount

RMAN> run {

2> set until time "to_date('2018-05-09 15:37:25','yyyy-mm-dd hh24:mi:ss')";                

3> restore database;

4> recover database;

5> alter database open resetlogs;

6> }

executing command: SET until clause

Starting restore at 09-MAY-18

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=7 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 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf

channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_09/o1_mf_nnndf_TAG20180509T153541_fh596frb_.bkp

channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_09/o1_mf_nnndf_TAG20180509T153541_fh596frb_.bkp tag=TAG20180509T153541

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 09-MAY-18

Starting recover at 09-MAY-18

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 09-MAY-18

database opened

至此,已完成恢复到指定时间点,在去查emp表的时,可以发现已经恢复。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ty_FFTQ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值