Oracle Rman archivelog
0x00 Rman的归档日志管理
archivelog的相关信息是记录在controlfile中的,当物理删除后不会改变controlfile的设置。并且在查询相关的动态视图(例如v$archived_log)时,该部分日志仍然标注为存在,也就是说
Oracle并不认为这些日志被删除。这种错误信息会导致在rman在备份archivelog终止,出现不能完成备份,并且阻塞后续的备份操作
1. 直接使用RMAN删除archivelog
RMAN>crosscheck archivelog all; RMAN>delete noprompt archivelog until time 'sysdate-3'; # 删除三天前的归档日志,不经过提示、直接删除。
RMAN>delete archivelog all completed before 'sysdate3';
2. 使用RMAN备份archivelog之后,进行删除动作
RMAN>backup format '/backup/archlog_%T_%s_%U' archivelog all delete input; # 这个表示备份所有的archivelog之后,删除所有路径下archivelog 因为有些库的archivelog 是多份的 RMAN>backup format '/backup/archlog_%T_%s_%U' archivelog all delete all input; # 在备份database的语句中加上plus archivelog; RMAN>backup database plus archivelog;
3. archivelog的检查,有时候管理员会在系统OS层面直接删除归档文件
# 首先进行archivelog 交叉检查 RMAN>crosscheck archivelog all; RMAN>delete noprompt expired archivelog all;
4. 查出某个时间段所涉及到的archivelog
RMAN>list backup of archivelog time between "to_date('2022-10-11 12:00:00','yyyy-mm-dd,hh24:mi:ss')" and "to_date('2022-10-31 12:00:00','yyyy-mm-dd hh24:mi:ss')";
# 根据以上查出的类容,我们就可以通过备份还原出archivelog
RMAN>restore archivelog from logseq 11111 until logseq 11150;
5. 与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 '/u03/rman/arch_log_%d_%T_%s_%p'; # 采用压缩备份所有归档 RMAN>backup as compressed backupset archivelog all format '/u03/rman/arch_log_%d_%T_%s_%p'; # 备份3天以来的归档日志 RMAN>backup archivelog from time 'sysdate-3'; # 从日志序列是5的开始备份 RMAN>backup archivelog from sequence 5; # 备份日志序列从5到10的日志 RMAN>backup archivelog from sequence 5 until sequence 10; # 备份完所有的日志后,删除所有归档目录的日志 RMAN>backup archivelog all delete all input; # 删除过期的archivelog RMAN>delete noprompt expired archivelog all; RMAN>restore archivelog all; # 还原所有的archivelog日志,不真实还原,只是预览操作 RMAN>restore archivelog all preview; # 删除所有的archivelog日志 RMAN>delete archivelog all; # 还原某个段的archivelog日志 RMAN>restore archivelog from logseq 11111 until logseq 11150; 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')" ;