until (3种)
1.scn 系统改变号
2.sequence 序列号
3.time 时间
time: 8:00 9:00 10:00 11:00
sequence: 1日志- 2日志 -3日志 -4日志 -5日志 -6日志
scn: 10000 20000 30000 40000
实验:
1.清除backup 全库备份 (alter database open resetlogs 强制打开数据库,日志会被全部删除,此时要重做全库备份很重要)
2.create table scott.test(id number)
3.归档模式下切日志 查询squence scn time
4.insert into scott.test values(1); commit;
5.查询日志 squence scn time 切换日志
6.insert 到6,commit;
7.把值等于5的日志移走,迁移数据库mv sytong1 sytong2 恢复到值4
1.
rman> rlwrap rman target /
rman> crosscheck backup;
rman> crosscheck archivelog all;
rman> delete obsolete;
rman> list backup; 如果还有备份信息=>delete noprompt force backup; 强制删除备份(生产中禁用)
2.create table scott.test(id number)
3.
select group#,status,sequence# from v$log; 查看日志文件序列号 oracle2当前是9
select current_scn from v$database; 3015861
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from v$database; 2014-01-11 22:01:39
alter system switch logfile; 10 切换日志
4.
insert into scott.test valuse(1);
commit;
select group#,status,sequence# from v$log; 10
select current_scn from v$database; 3015954
select to_char(sysdate,'yyy-mm-dd hh24:mi:ss) from v$database; 2014-01-11 22:01:50
alter system switch logfile;
依次插入到6,切换日志
5.
cd /opt/app/archive
mv 1_14_836554391.dbf /home/oracle/
rman> list backup;
mv sytong1 sytong2
mkdir sytong1
sql> statup
RMAN> restore controlfile from autobackup; (没开闪回,恢复不了)
rman> restore controlfile from '/opt/app/rman/full0_1uotqvvj_1_1.dbf'; (ll -ht 6.9M的那个备份片)
rman> alter database mount;
rman> alter database open; (报错 resetlogs强制打开 因为老的控制文件(restore)+最新的redo 如果都是新的则不需要强制)
rman> restore database;
rman> recover database; 日志会报错
sql> alter database open resetlogs;
sql> select * from scott.test;
1
2
3
4
--------------------------
目的不是这个 应该用until sequence恢复,执行结果相同。
重新mv sytong1 sytong2 mkdir sytong1
rman> startup
rman> restore controlfile from '/opt/app/rman/full0_1uotqvvj_1_1.dbf';
rman> alter database mount;
rman> run {
set until sequence 14 thread 1;
restore database;
recover database;
}
RMAN> alter database open resetlogs;
sql> select * from scott.test;
1
2
3
4
------------------------------------------------
把之前的mv的归档日志还原,就可以完全恢复,如果没有5号日志,只能恢复到4
$ mv /home/oracle/1_14_836554391.dbf /opt/app/archive/
redo联机日志、归档日志都在,可以把6条记录全部找回,控制文件+归档日志+联机日志进行恢复
$ rm -rf *.ctl (控制文件)
rman> startup
rman> restore controlfile from '/opt/app/rman/full0_1uotqvvj_1_1.dbf';
rman> alter database mount;
rman> run{
restore database;
recover database;
}
alter database open; (resetlogs报错就强制打开 )
select group#,status,sequence# from v$log; (resetlogs强制打开后sequence会归0)
sql> select * from scott.test
ID
----------
1
2
3
4
5
6
阅读(2316) | 评论(0) | 转发(0) |