欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle基于cancel的不完全恢复

程序员文章站 2022-06-05 22:16:43
...

实验:Oracle基于cancel的不完全恢复 实验环境查看 lsnrctl statusselect open_mode from v$database; --监听与数据库状态 show

实验:Oracle基于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)创建测试数据
SYS@ORA11GR2>create table scott.t1 as select 1 as id from dual;

Table created.

SYS@ORA11GR2>alter system archive log current;

System altered.

SYS@ORA11GR2>create table scott.t2 as select 2 as id from dual;

Table created.

SYS@ORA11GR2>alter system archive log current;

System altered.

SYS@ORA11GR2>create table scott.t3 as select 3 as id from dual;

Table created.

SYS@ORA11GR2>alter system archive log current;

System altered.

SYS@ORA11GR2>
SYS@ORA11GR2>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里面删除:
SYS@PROD>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

SYS@PROD>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


SYS@PROD>!rm /u01/app/oracle/oradata/PROD/datafile/*.dbf;

SYS@PROD>!rm /u01/app/oracle/oradata/PROD/onlinelog/*.log;

SYS@PROD>!rm /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模式
SYS@ORA11GR2>shutdown abort;
ORACLE instance shut down.
SYS@ORA11GR2>startup mount;
ORACLE instance started.