正德厚生,臻于至善

rman archivelog

因为archivelog的相关信息是记录在controlfile中的,当物理删除后不会改变controlfile的设置。并且在查询相关的动态视图(例如v$archived_log)时,该部分日志仍然标注为存在,也就是说

Oracle并不认为这些日志被删除了。

这种错误信息会导致在rman在备份archivelog终止,出现不能完成备份,并且阻塞后续的备份操作。

一、直接使用RMAN删除archivelog
RMAN> crosscheck archivelog all;
RMAN> delete noprompt archivelog until time ‘sysdate-3’;
删除三天前的归档日志,不经过提示、直接删除。
或者
RMAN> delete archivelog all completed before ‘sysdate-3’;

二、使用RMAN备份archivelog之后,进行删除动作。
RMAN> backup format ‘/backup/archlog_%T_%s_%U’ archivelog all delete input;


RMAN>backup format ‘/backup/archlog_%T_%s_%U’ archivelog all delete all input;
这个表示备份所有的archivelog之后,删除所有路径下archivelog 因为有些库的archivelog 是多份的。

或者在备份database的语句中加上plus archivelog;
RMAN>backup database plus archivelog;

三、如果是在OS层手工进行了archivelog或者文件丢失。
先进行archivelog 交叉检查
RMAN> crosscheck archivelog all;
RMAN> delete noprompt expired archivelog all;

四、查出某个时间段所涉及到的archivelog;
RMAN> list backup of archivelog time between “to_date(‘2012-04-12 12:00:00′,’yyyy-mm-dd,hh24:mi:ss’)” and “to_date(‘2012-04-25 12:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

根据以上查出的类容,我们就可以通过备份还原出archivelog
RMAN> restore archivelog from logseq 11111 until logseq 11150;

五、与archivelog相关的命令

RMAN> crosscheck archivelog all; —–交叉检查归档日志信息。
RMAN> list expired archivelog all; —–列出所有过期的归档日志信息。
RMAN> list archivelog all; —–查看当前归档日志列表信息。
RMAN> list archivelog from time=’sysdate-2′; —–查看至今两天的日志信息。
RMAN> backup archivelog all format ‘/backup/arch_log_%d_%T_%s_%p’; ——-备所有归档。
RMAN> backup as compressed backupset archivelog all format ‘/backup/arch_log_%d_%T_%s_%p’; ——-采用压缩,备所有归档。
RMAN> backup archivelog from time ‘sysdate-3’; ——-备份3天以来的归档日志。
RMAN> backup archivelog from sequence 5; ——-从日志序列是5的开始备份。
RMAN> backup archivelog from sequence 5 until sequence 10; ——-备份日志序列从5到10的日志。
RMAN> backup archivelog all delete all input; ——–备份完所有的日志后,删除所有归档目录的日志。
RMAN> delete noprompt expired archivelog all; ——–删除过期的archivelog
RMAN> restore archivelog all; ——–还原所有的archivelog日志
RMAN> restore archivelog all preview; ——–不真实还原,只是预览操作
RMAN> delete archivelog all; ——–删除所有的archivelog日志
RMAN> restore archivelog from logseq 11111 until logseq 11150; ——-还原某个段的archivelog日志
RMAN> restore archivelog from sequence 36 until sequence 50;
RMAN> restore archivelog low sequence 36 high sequence 50;
RMAN> restore archivelog time between “to_date(‘2012-04-22 10:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2012-04-26 16:20:00′,’yyyy-mm-dd hh24:mi:ss’)” preview;
RMAN> restore archivelog time between “to_date(‘2012-04-22 10:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2012-04-26 16:20:00′,’yyyy-mm-dd hh24:mi:ss’)” ;

指定archivelog的恢复目的地,如你想把archivelog恢复到一个临时目录时有用
RMAN> run {
set archivelog destination to ‘/home/temp’;
}

源文作者:http://hi.baidu.com/mydbonline/item/1021fc962d3258bc83d295cc

RMAN> list backup of archivelog all;
列出所有archive log 备份

RMAN> list backup of archivelog from logseq 100 until logseq 120;
列出archive log 从100到120

RMAN> list backup of archivelog sequence between 100 and 110;
列出archive log 从100到120
–说明:between……and只能使用sequence,而不能使用logseq

RMAN> list backup of archivelog from logseq 100;
列出seq大于等于100的archive log

RMAN> list backup of archivelog low logseq 120;
列出seq大于等于120的archive log

RMAN> list backup of archivelog sequence 100;
列出seq为100的archive log
–说明:在对于rman中关于archivelog的操作中logseq与sequence作用相同,但是建议尽量使用sequence

RMAN> list backup of archivelog logseq 85;
列出seq为85的archive log

RMAN> list backup of archivelog until logseq 85;
列出seq小于等于85的archive log

RMAN> list backup of archivelog high logseq 40;
列出seq小于等于40的archive log

RMAN> list backup of archivelog from time ‘sysdate-7′;
列出7天以前的archive log

RMAN> run {
set archivelog destination to ‘/backup’;
restore archivelog low logseq 40;
}
从seq为40开始,恢复到/backup中
–说明:list backup of archivelog中限定日志的位置也适合restore archivelog

RMAN> backup archivelog sequence between 100 and 110 format ‘/backup/text_test.rman’ delete input;
备份seq为100至110的archive log
–说明:list backup of archivelog中限定日志的位置也适合backup archivelog

RMAN>DELETE ARCHIVELOG ALL COMPLETED BEFORE ‘SYSDATE-7′;
删除7天前archive log

RMAN>DELETE ARCHIVELOG low logseq 40;
删除seq大于等于40的archive log

RMAN> crosscheck archivelog all;
RMAN> delete expired archivelog all;
删除无效archive log
–说明:DELETE ARCHIVELOG中限定日志的位置也适合restore archivelog

转自:http://www.xifenfei.com/1609.html

list backup of archivelog time between “to_date(‘2020-10-05 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

restore archivelog time between “to_date(‘2020-10-05 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-05 13:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

restore archivelog time between “to_date(‘2020-10-05 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

delete noprompt archivelog until time “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

select a.thread#, a.sequence#, a.applied
from v$archived_log a, v$database d
where a.activation# = d.activation#
and a.applied=’YES’
order by 1,2
/

list backup of archivelog from sequence 291826 thread 1 until sequence 291845 thread 1;

list backup of archivelog from sequence 356602 thread 2 until sequence 356614 thread 1;

restore archivelog from sequence 291827 thread 1 until sequence 291827 thread 1;

delete noprompt archivelog until sequence 291827 thread 1;
delete noprompt archivelog until sequence 356603 thread 2;

delete noprompt force archivelog until time “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

run {
set archivelog destination to “/nfsc/orabakup/ebsbackup/arch/restore”;
restore archivelog time between “to_date(‘2020-10-05 13:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;
}

cp /nfsc/orabakup/ebsbackup/arch/restore/* .

delete noprompt force archivelog time between “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-07 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

run {
set archivelog destination to “/nfsc/orabakup/ebsbackup/arch/restore”;
restore archivelog time between “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-07 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;
}

rman target / nocatalog <<EOF
run
{
set archivelog destination to “/nfsc/orabakup/ebsbackup/arch/restore”;
restore archivelog time between “to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-07 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;
}
exit
EOF

delete noprompt force archivelog time between “to_date(‘2020-10-07 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)” and “to_date(‘2020-10-08 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

###recover database until time=”to_date(‘2020-10-06 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)”;

delete noprompt archivelog until sequence 291853 thread 1;
delete noprompt archivelog until sequence 356623 thread 2;

restore archivelog from sequence 291853 thread 1 until sequence 291870 thread 1;
restore archivelog from sequence 356623 thread 2 until sequence 356640 thread 2;

delete noprompt archivelog until sequence 291870 thread 1;
delete noprompt archivelog until sequence 356640 thread 2;

crosscheck archivelog until sequence 291870 thread 1;
crosscheck archivelog until sequence 356640 thread 2;

alter database recover managed standby database cancel;
alter database recover managed standby database using current logfile disconnect from session;

赞(0) 打赏
未经允许不得转载:徐万新之路 » rman archivelog
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏