基于cancel的不完全恢复

实验:基于cancel的不完全恢复

实验环境查看

lsnrctl status

select open_mode from v$database;

--监听与数据库状态

show parameter recovery;

select flashback_on from v$database;

archive log list;

--闪回与归档的配置

1)准备环境:RMAN全库备份

RMAN> backup as compressed backupset full database;

--压缩备份

--backup full database ;备份集备份

Starting backup at 20-MAR-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=45 device type=DISK

channel ORA_DISK_1: starting compressed full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/ORA11GR2/system01.dbf

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

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

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

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

channel ORA_DISK_1: starting piece 1 at 20-MAR-13

channel ORA_DISK_1: finished piece 1 at 20-MAR-13

piece handle=/u01/app/FRA/ORA11GR2/backupset/2013_03_20/o1_mf_nnndf_TAG20130320T151949_8nlrrrfm_.bkp tag=TAG20130320T151949 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:17

channel ORA_DISK_1: starting compressed 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 20-MAR-13

channel ORA_DISK_1: finished piece 1 at 20-MAR-13

piece handle=/u01/app/FRA/ORA11GR2/backupset/2013_03_20/o1_mf_ncsnf_TAG20130320T151949_8nlrx2qs_.bkp tag=TAG20130320T151949 comment=NONE

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

Finished backup at 20-MAR-13

2)创建测试数据

[email protected]>create table scott.t1 as select 1 as id from dual;

Table created.

[email protected]>alter system archive log current;

System altered.

[email protected]>create table scott.t2 as select 2 as id from dual;

Table created.

[email protected]>alter system archive log current;

System altered.

[email protected]>create table scott.t3 as select 3 as id from dual;

Table created.

[email protected]>alter system archive log current;

System altered.

[email protected]>

[email protected]>select table_name,tablespace_name from dba_tables where owner=‘SCOTT‘ AND table_name LIKE ‘T_‘;

TABLE_NAME                   TABLESPACE_NAME

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

T3                             USERS

T2                             USERS

T1                             USERS

完成测试数据构造后,查看生成的归档日志

ls /u01/app/oracle/fast_recovery_area/PROD/archivelog/2014_10_08

ls -lrt

3)删除所有数据文件和在线数据文件

在sqlplus里面删除:

[email protected]>select name from v$datafile;

NAME

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

/u01/app/oracle/oradata/PROD/datafile/o1_mf_system_b2251bs1_.dbf

/u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_b2251bvo_.dbf

/u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_b2251bw5_.dbf

/u01/app/oracle/oradata/PROD/datafile/o1_mf_users_b2251byw_.dbf

/u01/app/oracle/oradata/PROD/datafile/o1_mf_example_b2257d0c_.dbf

/u01/app/oracle/oradata/PROD/datafile/tbs_move_01.dbf

[email protected]>select member from v$logfile;

MEMBER

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

/u01/app/oracle/oradata/PROD/onlinelog/o1_mf_3_b22567o2_.log

/u01/app/oracle/fast_recovery_area/PROD/onlinelog/o1_mf_3_b2256827_.log

/u01/app/oracle/oradata/PROD/onlinelog/o1_mf_2_b2255zsg_.log

/u01/app/oracle/fast_recovery_area/PROD/onlinelog/o1_mf_2_b22560gb_.log

/u01/app/oracle/oradata/PROD/onlinelog/o1_mf_1_b2255npg_.log

/u01/app/oracle/fast_recovery_area/PROD/onlinelog/o1_mf_1_b2255nxl_.log

[email protected]>!rm /u01/app/oracle/oradata/PROD/datafile/*.dbf;

[email protected]>!rm /u01/app/oracle/oradata/PROD/onlinelog/*.log;

[email protected]>!rm /u01/app/oracle/fast_recovery_area/PROD/onlinelog/*.log;

在OS里面删除:

[[email protected] ORA11GR2]$ pwd

/u01/app/oracle/oradata/ORA11GR2

[[email protected] ORA11GR2]$ ls

control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf

control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf

[[email protected] ORA11GR2]$ rm *.log

[[email protected] ORA11GR2]$ ls

control01.ctl  example01.dbf  system01.dbf  undotbs01.dbf

control02.ctl  sysaux01.dbf   temp01.dbf    users01.dbf

[[email protected] ORA11GR2]$

4)数据库启动到mount模式

[email protected]>shutdown abort;

ORACLE instance shut down.

[email protected]>startup mount;

ORACLE instance started.

Total System Global Area  841162752 bytes

Fixed Size                  1339768 bytes

Variable Size             532680328 bytes

Database Buffers          301989888 bytes

Redo Buffers                5152768 bytes

Database mounted.

[email protected]>

5)RMAN还原数据库

RMAN> restore database;

Starting restore at 20-MAR-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=18 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 /u01/app/oracle/oradata/ORA11GR2/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ORA11GR2/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ORA11GR2/example01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/FRA/ORA11GR2/backupset/2013_03_20/o1_mf_nnndf_TAG20130320T151949_8nlrrrfm_.bkp

channel ORA_DISK_1: piece handle=/u01/app/FRA/ORA11GR2/backupset/2013_03_20/o1_mf_nnndf_TAG20130320T151949_8nlrrrfm_.bkp tag=TAG20130320T151949

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:03:26

Finished restore at 20-MAR-13

RMAN>

6)基于cancel恢复

[email protected]>recover database until cancel;

--在sqlplus中完成

ORA-00279: change 883460 generated at 03/20/2013 15:19:50 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/ORA11GR2/archivelog/2013_03_20/o1_mf_1_8_8nlrzy8w_.arc

ORA-00280: change 883460 for thread 1 is in sequence #8

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

--应用sequence #8为8,名字为o1_mf_1_8_8nlrzy8w_.arc的归档日志文件,直接按回车键

ORA-00279: change 884069 generated at 03/20/2013 15:23:42 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/ORA11GR2/archivelog/2013_03_20/o1_mf_1_9_8nls091w_.arc

ORA-00280: change 884069 for thread 1 is in sequence #9

ORA-00278: log file

‘/u01/app/FRA/ORA11GR2/archivelog/2013_03_20/o1_mf_1_8_8nlrzy8w_.arc‘ no longer

needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

--应用sequence #9为9的这个归档日志文件,直接按回车键

ORA-00279: change 884101 generated at 03/20/2013 15:23:53 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/ORA11GR2/archivelog/2013_03_20/o1_mf_1_10_8nls0os6_.arc

ORA-00280: change 884101 for thread 1 is in sequence #10

ORA-00278: log file

‘/u01/app/FRA/ORA11GR2/archivelog/2013_03_20/o1_mf_1_9_8nls091w_.arc‘ no longer

needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

--手动输入cancel结束恢复,不管后面有没有可恢复文件,都会结束;

Media recovery cancelled.

[email protected]>

[email protected]>alter database open resetlogs;

Database altered.

[email protected]>

7)检查

[email protected]>select table_name,tablespace_name from dba_tables where owner=‘SCOTT‘ AND table_name LIKE ‘T_‘;

TABLE_NAME                   TABLESPACE_NAME

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

T2                             USERS

T1                             USERS

[email protected]>

注 应用了两个归档日志,第三个归档日志cancel了,从结果中也可以看到,恢复以后的数据库中,只

存在T1,T2两张表,它们俩的重做日志就在前两个归档中,T3表的所有重做条目都在第三个归档中,

由于采取了cancel,所以,T3表并未恢复

时间: 2024-08-25 04:11:36

基于cancel的不完全恢复的相关文章

基于Innobackupex的不完全恢复

对于MySQL的不完全恢复,我们可以借助于Innobackupex的多重备份加上binlog来将数据库恢复到任意时刻.这里的不完全恢复(也叫时点恢复)是相对于完全恢复.本文主要演示了基于Innobackupex如何做一个不完全恢复,供大家参考. 有关Innobackupex的备份恢复的知识点请参考以下链接:        Innobackupex 全备数据库        使用mysqlbinlog提取二进制日志        基于Innobackupex的全备恢复         基于Inno

人工手动冷备不完全恢复介绍(purge表不完全恢复)

不完全恢复 不完全恢复的基本类型:1)基于时间点 (until time): 使整个数据库恢复到过去的一个时间点前2)基于scn (until change): 使整个数据库恢复到过去的某个SCN前3)基于cancel (until cancel): 使整个数据库恢复到归档日志或当前日志的断点前 不完全恢复(Incomplete recover) 适用环境:1)在过去的某个时间点重要的数据被破坏.2)在做完全恢复时,丢失了归档日志或当前online redo log3)当误删除了表空间时(有控制

oracle数据库完全恢复和不完全恢复以及执行用户管理辈分恢复

比较完全恢复和不完全恢复: 一.完全恢复:将数据库恢复到当前最新状态,包括直至请求恢复时进行的所有已提交的数据更改 二.不完全恢复:将数据库恢复到请求恢复操作之前指定的过去时间点 一.完全恢复过程 下面的步骤说明了执行完全恢复期间要采取的操作: 1. 通过备份还原损坏或丢失的文件. 2. 根据需要应用增量备份.归档重做日志文件和联机重做日志文件中的更改.将重做日志更改应用于数据文件,直到到达当前联机日志,并且重新输入了最新的事务处理.在整个过程中会生成还原块.这称为前滚或高速缓存恢复. 3. 此

Oracle 基于用户管理恢复的处理

================================ -- Oracle 基于用户管理恢复的处理 --================================ Oracle支持多种方式来管理数据文件的备份与恢复来保证数据库的可靠与完整.除了使用RMAN工具以及第三方备份与恢复工具之外,基于 用户管理的备份与恢复也是DBA经常使用的方式之一.本文首先介绍了恢复的相关概念,接下来详细讲述了在归档模式下使用基于用户管理恢 复的处理过程. 一.恢复的相关概念 介质恢复 首先使用备份还

Oracle 手工不完全恢复总结(一)

完全恢复和不完全恢复都是对数据库进行恢复的操作. 完全恢复:指的是利用重做日志或增量备份将数据恢复到最近的当前时间点.回滚未提交事务.之所以叫完全恢复是由于Oracle应用了归档日志和联机重做日志中的所有的修改. 不完全恢复:利用备份产生一个非当前版本的数据库.恢复过程中不会应用备份产生后生成的所有重做日志. 不完全恢复应用的场景: 介质失败.损坏了一个.几个或全部的联机重做文件: 用户操作造成的数据丢失,比如用户误删除一张表: 由于个别归档日志文件的丢失: 丢失了当前的控制文件,必须使用备份的

冷备手工完全恢复(recover database,recover tablespace,recover datafile)

冷备手工完全恢复 1.   手工完全恢复三种级别: recover database: 所有或大部分datafile丢失,一般是在mount状态完成.recover tablespace:    非关键表空间损坏,表空间下某些数据文件不能访问,一般是在open下完成.recover datafile: 单一或少数数据文件损坏,可以在mount或open 状态完成.四个关键文件:1)system01.dbf, 2) undo tablespace,3)control file 4)current

【恢复】Redo日志文件丢失的恢复

第一章 Redo文件丢失的恢复 1.1  online redolog file 丢失 联机Redo日志是Oracle数据库中比较核心的文件,当Redo日志文件异常之后,数据库就无法正常启动,而且有丢失据的风险,强烈建议在条件允许的情况下,对Redo日志进行多路镜像.需要注意的是,RMAN不能备份联机Redo日志文件.所以,联机Redo日志一旦出现故障,则只能进行清除日志了.清除日志文件即表明可以重用该文件. 1.1.1  数据库归档/非归档模式下inactive redo异常ORA-00316

backup与recover

完全恢复: 1.关闭DB2.拷贝文件3.启动DB.<出错>startup mount4.recover database until cancel using backup controlfile;5.alter database open resetlogs; 一.数据库是打开状态,系统表空间和undo表空间未损坏. 1.表空间offline 2.拷贝备份文件 3.执行恢复操作recover tablespace 名字 或recover datafile # 4.表空间online 二.数据

如何Oracle 数据库备份与恢复

转自一位大神的笔记. 一. 理解什么是数据库恢复  当我们使用一个数据库时,总希望数据库的内容是可靠的.正确的,但由于计算机系统的故障(硬件故障.软件故障.网络故障.进程故障和系统故障)影响数据库系统的操作,影响数据库中数据的正确性,甚至破坏数据库,使数据库中全部或部分数据丢失.因此当发生上述故障后,希望能重构这个完整的数据库,该处理称为数据库恢复.恢复过程大致可以分为复原(Restore)与恢复(Recover)过程. 数据库恢复可以分为以下两类: 1.1实例故障的一致性恢复 当实例意外地(如