博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基于cancel的不全然恢复
阅读量:6705 次
发布时间:2019-06-25

本文共 7192 字,大约阅读时间需要 23 分钟。

实验:基于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)创建測试数据

table scott.t1 as select 1 as id from dual;

Table created.

system archive log current;

System altered.

table scott.t2 as select 2 as id from dual;

Table created.

system archive log current;

System altered.

table scott.t3 as select 3 as id from dual;

Table created.

system archive log current;

System altered.

>

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里面删除:

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

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

/u01/app/oracle/oradata/PROD/datafile/*.dbf;

/u01/app/oracle/oradata/PROD/onlinelog/*.log;

/u01/app/oracle/fast_recovery_area/PROD/onlinelog/*.log;

在OS里面删除:
[oracle@ocmu ORA11GR2]$ pwd
/u01/app/oracle/oradata/ORA11GR2
[oracle@ocmu ORA11GR2]$ ls
control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf
[oracle@ocmu ORA11GR2]$ rm *.log
[oracle@ocmu ORA11GR2]$ ls
control01.ctl  example01.dbf  system01.dbf  undotbs01.dbf
control02.ctl  sysaux01.dbf   temp01.dbf    users01.dbf
[oracle@ocmu ORA11GR2]$

4)数据库启动到mount模式
abort;
ORACLE instance shut down.
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.
>

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恢复
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.
>
database open resetlogs;

Database altered.

>

7)检查
table_name,tablespace_name from dba_tables where owner='SCOTT' AND table_name LIKE 'T_';

TABLE_NAME                   TABLESPACE_NAME

------------------------- ------------------------------
T2                             USERS
T1                             USERS

>

注 应用了两个归档日志。第三个归档日志cancel了。从结果中也能够看到。恢复以后的数据库中。仅仅
 存在T1,T2两张表,它们俩的重做日志就在前两个归档中,T3表的全部重做条目都在第三个归档中,
 因为採取了cancel,所以,T3表并未恢复

转载地址:http://vsflo.baihongyu.com/

你可能感兴趣的文章
Spring源代码解析(六):Spring声明式事务处理
查看>>
精心挑选12款优秀的 JavaScript 日历和时间选择插件
查看>>
iphone sdk
查看>>
如何获取jqGrid中选择的行的数据
查看>>
Android 获取自带浏览器上网记录
查看>>
c++ 静态持续变量
查看>>
MFC超链接静态类的使用
查看>>
我所遭遇过的游戏中间件---SpeedTree
查看>>
csharp .net vb 复制图像
查看>>
android:versionCode和android:versionName 用途(转)
查看>>
android之SeekBar控件用法
查看>>
Fragment Transactions & Activity State Loss
查看>>
jQuery插件 -- 表单验证插件jquery.validate.js
查看>>
我的MYSQL学习心得(十四) 备份和恢复
查看>>
nodejs express 安装
查看>>
flume-ng-elasticsearch 索引时间命名问题(时区和时间格式)
查看>>
PE文件结构学习
查看>>
pthread_setschedparam
查看>>
在对listctrl的控件进行重载的过程中,GetHeaderCtrl()返回NULL的问题
查看>>
WEB网站前端性能分析相关
查看>>