您好,登录后才能下订单哦!
RMAN> backup incremental level=0 database format '/home/oracle/rman/%U';
SYS@prod>create table test as select * from dba_objects;
Table created.
SYS@prod>insert into test select * from test;
86959 rows created.
SYS@prod>/
173918 rows created.
SYS@prod>/
347836 rows created.
SYS@prod>insert into test select * from test;
695672 rows created.
SYS@prod>commit;
Commit complete
SYS@prod>select count(*) from test;
COUNT(*)
----------
1391344
SYS@prod>select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
2 ACTIVE
3 CURRENT
查看当前控制文件头部和数据文件头部 SCN号:
SYS@prod>select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1198910
1198910
1198910
1198910
1198910
SYS@prod>select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1198984
1198984
1198984
1198984
1198984
进行一次增量备份:
RMAN> backup incremental level=1 database format '/home/oracle/rman/%U';
然后再次查看SCN:
SYS@prod>select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1199201
1199201
1199201
1199201
1199201
SYS@prod>select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1199201
1199201
1199201
1199201
1199201
SYS@prod>select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
3 CURRENT
可以看出:SCN 号同步刷新,日志组状态改变, RMAN 备份与热备份性质一样,都会在备份前做一个完全检查点,将脏块刷新回数据文件。
此时删除全部的文件进行恢复:
[oracle@service1 prod]$ ls
control01.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
example01.dbf redo02.log sysaux01.dbf temp01.dbf users01.dbf
[oracle@service1 prod]$ rm -rf *
[oracle@service1 ~]$ sqlplus / as sysdba
SYS@prod>shutdown abort;
SYS@prod>startup nomount;
[oracle@service1 ~]$ rman target /
RMAN> restore controlfile from '/home/oracle/rman/1mv1thi1_1_1';
RMAN> sql ' alter database mount';
RMAN> restore database;
RMAN> recover database
Starting recover at 04-JUN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=125 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata/prod/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/prod/sysaux01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/prod/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/prod/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/prod/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/1lv1thgk_1_1
channel ORA_DISK_1: piece handle=/home/oracle/rman/1lv1thgk_1_1 tag=TAG20200604T130939
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
starting media recovery
unable to find archived log
archived log thread=1 sequence=6
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/04/2020 13:17:35
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 6 and starting SCN of 1199201
这个错误是什么原因呢:
(redo 日志不可用,控制文件找不到 redo 日志作为结尾,所以会一直读归档,直至找不到,无关紧要的报错,可以查看 SCN 来确定是否一致)
在RMAN恢复过程中,如果redo日志是可用的,那么RMAN可以找到他们并应用这些日志。如果redo日志不可用,此时就需要until子句指定修复的目标时间,SCN或日志序列号,他们是在联机重做日志的第一个SCN之前,否则RMAN会出现RMAN-6054错误。
如果最后创建的归档日志具有序列号n,那么指定until sequence n+1进行恢复就不会出现错误。
解决办法:
Run{
Restore database
Set until sequence 6
Recover database
}
SYS@prod>select checkpoint_change# from v$datafile;
CHECKPOINT_CHANGE#
------------------
1199201
1199201
1199201
1199201
1199201
SYS@prod>select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
1199201
1199201
1199201
1199201
1199201
SYS@prod>alter database open resetlogs;
Database altered.
SYS@prod>select count(*) from test;
COUNT(*)
----------
1391344
数据无丢失。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。