【Oracle】 rman 删除归档日志的命令-阿里云开发者社区

开发者社区> yangyi_dba> 正文

【Oracle】 rman 删除归档日志的命令

简介:     因为数据仓库上asm的磁盘空间不足,需要删除早期的归档日志,查看资料有以下两种方式: delete archivelog until time 'sysdate-N'; delete archivelog all completed before 'sysdate-N'; 这两个命令的差别在哪里呢? 使用list 命令来查看一下究竟.
+关注继续查看
    因为数据仓库上asm的磁盘空间不足,需要删除早期的归档日志,查看资料有以下两种方式:
delete archivelog until time 'sysdate-N';
delete archivelog all completed before 'sysdate-N';
这两个命令的差别在哪里呢?
使用list 命令来查看一下究竟...
RMAN>  list archivelog until time 'sysdate-1';
using target database control file instead of recovery catalog
List of Archived Log Copies for database with db_unique_name YANGDB
=====================================================================
Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
459     1    463     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_463_762800109.log
460     1    464     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_464_762800109.log
461     1    465     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_465_762800109.log
462     1    466     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_466_762800109.log
463     1    467     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_467_762800109.log
464     1    468     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_468_762800109.log
465     1    469     A 10-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_469_762800109.log
466     1    470     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_470_762800109.log
467     1    471     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_471_762800109.log
468     1    472     A 12-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_472_762800109.log
469     1    473     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_473_762800109.log
470     1    474     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_474_762800109.log
471     1    475     A 14-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_475_762800109.log
472     1    476     A 15-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_476_762800109.log
归档日志的序列号码到476
RMAN> list archivelog all completed before 'sysdate-1';
List of Archived Log Copies for database with db_unique_name YANGDB
=====================================================================
Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
459     1    463     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_463_762800109.log
460     1    464     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_464_762800109.log
461     1    465     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_465_762800109.log
462     1    466     A 08-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_466_762800109.log
463     1    467     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_467_762800109.log
464     1    468     A 09-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_468_762800109.log
465     1    469     A 10-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_469_762800109.log
466     1    470     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_470_762800109.log
467     1    471     A 11-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_471_762800109.log
468     1    472     A 12-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_472_762800109.log
469     1    473     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_473_762800109.log
470     1    474     A 13-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_474_762800109.log
471     1    475     A 14-JAN-12 Name: /opt/oracle/yangdb_arch/yangdb_1_475_762800109.log
归档日志的序列号码到475 
查看v$archived_log 视图从中获取 时间和序列号信息!
SYS@yangdb> select THREAD#,sequence#,FIRST_TIME,COMPLETION_TIME  
2   from v$archived_log order by thread#,sequence#;

THREAD# SEQUENCE# FIRST_TIME      COMPLETION_TIME
------- ---------- -------------- -------------------
1        470  2012-01-11 11:00:10  2012-01-11 22:08:23
1        471  2012-01-11 22:08:20  2012-01-12 17:00:10
1        472  2012-01-12 17:00:10  2012-01-13 02:00:28
1        473  2012-01-13 02:00:28  2012-01-13 22:09:56
1        474  2012-01-13 22:09:55  2012-01-14 22:01:02
1        475  2012-01-14 22:01:02  2012-01-15 06:46:14 ==list archivelog all completed 以COMPLETION_TIME为基准   
1        476  2012-01-15 06:46:14  2012-01-30 14:10:18 ==list archivelog until 以FIRST_TIME 为基准 编号476的日志横跨15号和30号两天,以first_time的值来截取!
1        477  2012-01-30 14:10:15  2012-01-30 14:10:23
1        478  2012-01-30 14:10:22  2012-01-30 14:10:29
1        479  2012-01-30 14:10:28  2012-01-30 14:10:33
1        480  2012-01-30 14:10:32  2012-01-30 14:10:40  

总结:
delete archivelog until time 'sysdate-N';
该命令删除日志时的时间基准是first_name
delete archivelog all completed before 'sysdate-N';
该命令删除日志时的时间基准是completion_time   

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
alert日志中的两种ORA错误分析
今天在巡检系统的时候,发现alert日志中有两种类型的ora错误。 Errors in file /U01/app/oracle/diag/rdbms/XX/XX/trace/xxdb_j002_20401.
919 0
怎么设置阿里云服务器安全组?阿里云安全组规则详细解说
阿里云服务器安全组设置规则分享,阿里云服务器安全组如何放行端口设置教程
8408 0
Oracle创建删除用户、角色、表空间、导入导出、...命令总结
http://www.iteye.com/topic/620306/   查询表空间名字和状态 select tablespace_name,status FROM dba_tablespa...
482 0
Mac PD虚拟机卸载删除
MAC 10.12.6 从Application直接删掉PD Mac盘--》资源庫--》preference--》删掉parallels
1103 0
+关注
yangyi_dba
数据库相关技术专家
972
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载