Oracle RMAN 备份及不完全恢复(删除archievelog)

RMAN备份命令


backup Database format=‘/home/oracle/backup/bak_full_%U_%T‘ tag=‘bak_full‘; 
sql ‘alter system archive log current‘; 
backup archivelog all tag=‘arc_bak‘ format=‘/home/oracle/backup/arch_%U_%T‘ delete input; 
backup current controlfile tag=‘bak_ctlfile‘ format=‘/home/oracle/backup/bak_ctl_%U_%T‘; 
backup spfile tag=‘spfile‘ format=‘/home/oracle/backup/bak_spfile_%U_%T‘;

备份完后插入测试数据

insert into zz values(2); commit;

insert into qq values(2); commit;

然后通过alter system switch logfile多切几次归档,切出多个归档文件

o1_mf_1_12_cpb2xhg8_.arc o1_mf_1_14_cpb36dbo_.arc
o1_mf_1_13_cpb35zgs_.arc o1_mf_1_15_cpb37ff2_.arc

删除12和14文件

[[email protected] 2016_06_18]$ rm o1_mf_1_12_cpb2xhg8_.arc
[[email protected] 2016_06_18]$ rm o1_mf_1_14_cpb36dbo_.arc

通过在RMAN中运行处理使得报错

run {

sql‘alter database datafile 6 offline‘;

restore datafile 6;

recover datafile 6;

sql‘alter database datafile 6 online‘;

}

错误为


RMAN> recover datafile 6;

Starting recover at 18-JUN-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 13 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_13_cpb35zgs_.arc
archived log for thread 1 with sequence 15 is already on disk as file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_15_cpb37ff2_.arc
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/18/2016 16:59:59
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 14 and starting SCN of 1105737 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 12 and starting SCN of 1080714 found to restore

查看archieve目录,发现确实只有

o1_mf_1_13_cpb35zgs_.arc  o1_mf_1_15_cpb37ff2_.arc

查看v$log,得到最后需要应用的日志文件应该是16

SQL> select group#,sequence#,status from v$log;

GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 16 CURRENT
2 14 INACTIVE
3 15 INACTIVE

被还原的6号文件的scn为

SQL> select file#,change# from v$recover_file;

FILE# CHANGE#
---------- ----------
6 1080514

查看v$log_history得知需要从10号文件开始恢复

SQL> select sequence# from v$log_history where 1080514 between first_change# and next_change#-1;

SEQUENCE#
----------
10

RMAN> list backup of archivelog all;

List of Backup Sets
===================

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
3 61.04M DISK 00:00:03 16-JUN-16
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20160616T165323
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2016_06_16/o1_mf_annnn_TAG20160616T165323_cp4t83nk_.bkp

List of Archived Logs in backup set 3
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 6 1022418 08-JUN-16 1033516 16-JUN-16
1 7 1033516 16-JUN-16 1047305 16-JUN-16

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
4 61.05M DISK 00:00:02 16-JUN-16
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20160616T165445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2016_06_16/o1_mf_annnn_TAG20160616T165445_cp4tbogp_.bkp

List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 6 1022418 08-JUN-16 1033516 16-JUN-16
1 7 1033516 16-JUN-16 1047305 16-JUN-16
1 8 1047305 16-JUN-16 1047358 16-JUN-16

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 61.02M DISK 00:00:03 18-JUN-16
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: ARC_BACK
Piece Name: /home/oracle/backup/arch_07r8fcti_1_1_20160618

List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 9 1047358 16-JUN-16 1071119 16-JUN-16
1 10 1071119 16-JUN-16 1080684 18-JUN-16
1 11 1080684 18-JUN-16 1080714 18-JUN-16

备份级里面有6,7,8,9,10,11,6号文件test01.dbf需要的是从10号archivelog开始,但需要恢复到16号文件,目前缺少12,14文件.

查找一下12-14文件的位置,进行确认.

RMAN> list archivelog low sequence 12 high sequence 14

2> ;

List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - ---------
7 1 12 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_12_cpb2xhg8_.arc

8 1 13 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_13_cpb35zgs_.arc

9 1 14 A 18-JUN-16
Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_14_cpb36dbo_.arc

只能不完全恢复到12

shutdown abort;

starup force mount;


RMAN> run {
2> set until sequence 12;
3> restore database;
4> }

executing command: SET until clause

Starting restore at 18-JUN-16
using channel ORA_DISK_1
flashing back control file to SCN 1080714

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/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/test01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/back_full_05r8fcon_1_1_20160618
channel ORA_DISK_1: piece handle=/home/oracle/backup/back_full_05r8fcon_1_1_20160618 tag=BACK_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 18-JUN-16

RMAN> run {
2> set until sequence 12;
3> recover database;
4> }

executing command: SET until clause

Starting recover at 18-JUN-16
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=10
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=11
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/arch_07r8fcti_1_1_20160618
channel ORA_DISK_1: piece handle=/home/oracle/backup/arch_07r8fcti_1_1_20160618 tag=ARC_BACK
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_10_cpb4clcf_.arc thread=1 sequence=10
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_10_cpb4clcf_.arc RECID=20 STAMP=914865395
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_11_cpb4clcl_.arc thread=1 sequence=11
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2016_06_18/o1_mf_1_11_cpb4clcl_.arc RECID=19 STAMP=914865394
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-JUN-16

RMAN> alter database open resetlogs;

database opened

用scott/tiger登录后查看,发现插入的数据不在了.

时间: 2024-10-24 05:39:48

Oracle RMAN 备份及不完全恢复(删除archievelog)的相关文章

Oracle Rman备份脚本与自动删除重复备份文件

#!/bin/sh source /home/oracle/.bash_profile if [ -z $1 ] then echo "Please Input a number,Usage: 0|1|2" exit else RMAN_LEVEL=$1 fi export ORACLE_SID=xxxx export TODAY=`date '+%Y%m%d'` export RMAN_DIR=/backup/archivelog/rman/$ORACLE_SID/$TODAY-$R

ORACLE RMAN备份及还原 RMAN可以进行增量备份:数据库,表空间,数据文件

ORACLE RMAN备份及还原 RMAN可以进行增量备份:数据库,表空间,数据文件 只有使用过的block可以被备份成backup set 表空间与数据文件对应关系:dba_data_files / v$datafile_header 在noarchivelog模式下,可以使用RMAN备份read-only和offline的表空间 ORACLE RMAN停机备份: 备份 RMAN连接上ORACLE,WINDOWS下在命令模式下 RMAN TARGET / 连接本地数据库用的是本地认证模式.RM

Oracle RMAN备份恢复2-案例篇_超越OCP精通Oracle视频教程培训18

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库如何设计一个TB级数据库的RMAN备份策略,RMAN备份与恢复案例-丢失所有文件,丢失单个数据文件,丢失整个数据和system表空间,丢失控制文件和参数文件,存储损坏数据丢失,丢失REDO重做日志文件,基于时间点,scn,cancel,备份控制文件的不完成恢复案例. 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: http://edu.51c

Oracle RMAN备份中catalog和nocatalog区别

nocatalog方式:用control file作为catalog,每一次备份都要往控制文件里面写好多备份信息,控制文件里面会有越来越多的备份信息,即RMAN的备份信息写在本地控制文件里面. catalog方式:必须要首先要创建目录备份数据库(catalog,也称知识库),建立恢复目录,即数据库的备份信息写到恢复目录里面. 当通过rman nocatalog方式备份Oracle数据库,Oracle使用controlfile存放RMAN的备份信息.因此,当使用Rman nocatalog方式备份

Oracle RMAN 备份一例

Oracle RMAN备份一例: Solaris 10 + Oracle 11.2.0.3 Shell:csh 备份策略:周日0级备份,周一~周六1级备份,每6小时备份归档日志,每天清理历史文件夹. --0级备份脚本: #!/bin/csh #db0 level backup foldername=`date +%Y%m%d` cd /oradata1/backup if [ -d $foldername ] then echo 'go on' else echo 'need mkdir' mk

Oracle RMAN备份深入解析--联机备份

Oracle RMAN备份深入解析--联机备份 RMAN> backup database plus archivelog;    1.首先,进程使用alter system archivelog current命令完成了日志切换操作.    2.进程将现存所有归档重做日志备份    3.开始执行实际的数据库备份操作,此时会发生一次日志切换(alter system archivelog current),同时RMAN备份剩余的归档重做日志(使用backup archivelog all命令).

ORACLE RMAN备份--差异增量与累积增量的策略实例图

转自原文 ORACLE RMAN备份--差异增量与累积增量的策略实例图 BACKUP 命令在不显式指定的情况下,默认情况下会选择Differential方式,即差异增量备份.不过从恢复效率的角度考虑,Cumulative方式的增量备份表现更好一些,毕竟不需要读取那么多备份集了. 注意: 在10g之前的版本中,增量备份可以有 n 多个级别,从0级.1级.2级……这样顺序排列直到 n 级( n 为小于等于4的正整数). 在10g版本中,Oarcle的官方文档明确指出增量备份只有0和1两种级别(太多增

Oracle RMAN备份恢复1-基础篇_超越OCP精通Oracle视频教程培训17

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库RMAN备份恢复基础,如rman作用与体系架构,nocatalog和catalog介绍与catalog配置,详解rman的使用,详解rman常用的命令list,report, backup,configure,set,crosscheck,validate,change,delete,restore,recover,switch,blockrecover,convert等使用. 适用人群 IT相关从

Oracle RMAN备份恢复3-高级篇_超越OCP精通Oracle视频课程培训19

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库关于RMAN内存缓冲与块跟踪,DBMS_BACKUP_RESTORE,使用RMAN BlockRecover恢复坏块,RMAN Recovery Advisor 案例,RMAN备份压缩技术,RMAN增量备份恢复,RMAN备份加密,RMAN克隆数据库,生产环境RMAN异机恢复的几种经典场景案例 . 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: