others linux服务器运维 django3 监控 k8s golang 数据库 大数据 前端 devops 理论基础 java oracle 运维日志

oracle 清理闪回区 清理归档日志 清理备份

访问量:1834 创建时间:2021-04-13

查看闪回区被什么内容占用(我这里是rman backup database占满,一般还可能是归档日志占满)

RMAN> select file_type, percent_space_used as used,percent_space_reclaimable as reclaimable, number_of_files from v$flash_recovery_area_usage;

FILE_TYPE                     USED RECLAIMABLE NUMBER_OF_FILES
----------------------- ---------- ----------- ---------------
CONTROL FILE                     0           0               0
REDO LOG                         0           0               0
ARCHIVED LOG                     0           0               0
BACKUP PIECE                 66.55           0               1
IMAGE COPY                       0           0               0
FLASHBACK LOG                    0           0               0
FOREIGN ARCHIVED LOG             0           0               0
AUXILIARY DATAFILE COPY          0           0               0

清理rman备份的pieces

[oracle@esbqasdb ~]$ rm -rf /oracle/u01/app/oracle/fast_recovery_area/esbqas/ESBQAS/95B78606708A2A49E0531200A8C08673/backupset

RMAN> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/oracle/u01/app/oracle/fast_recovery_area/esbqas/ESBQAS/95B78606708A2A49E0531200A8C08673/backupset/2021_04_13/o1_mf_nnndf_TAG20210413T144753_j7bhnw30_.bkp RECID=1 STAMP=1069771676
Crosschecked 1 objects


RMAN> delete expired backup;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1       1       1   1   EXPIRED     DISK        /oracle/u01/app/oracle/fast_recovery_area/esbqas/ESBQAS/95B78606708A2A49E0531200A8C08673/backupset/2021_04_13/o1_mf_nnndf_TAG20210413T144753_j7bhnw30_.bkp

Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/oracle/u01/app/oracle/fast_recovery_area/esbqas/ESBQAS/95B78606708A2A49E0531200A8C08673/backupset/2021_04_13/o1_mf_nnndf_TAG20210413T144753_j7bhnw30_.bkp RECID=1 STAMP=1069771676
Deleted 1 EXPIRED objects


RMAN>  crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1905 device type=DISK
specification does not match any archived log in the repository

RMAN> delete expired archivelog all;

清理归档日志

rman命令 用处
crosscheck archivelog all;                             校验日志的可用性
list expired archivelog all;                           列出所有失效的归档日志
delete archivelog until sequence 16;                   删除log sequence为16及16之前的所有归档日志
delete archivelog all completed before 'sysdate-7';    删除系统时间7天以前的归档日志,不会删除闪回区有效的归档日志
delete archivelog all completed before 'sysdate - 1';  同上,1天以前的
delete archivelog from time 'sysdate-1';               注意这个命令,删除系统时间1天以内到现在的归档日志
delete noprompt archivelog all completed before 'sysdate';   该命令清除所有的归档日志
delete noprompt archivelog all;                              同上一命令

清理备份

#查看备份
RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    18.07G     DISK        00:04:35     13-APR-21      
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20210413T154621
        Piece Name: /oracle/backup/ESB_ful_03vs6uad_1_1
  List of Datafiles in backup set 2
  Container ID: 3, PDB Name: ESBQASPDB
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
#省略部分输出###############

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3       Full    18.16M     DISK        00:00:01     13-APR-21      
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20210413T155107
        Piece Name: /oracle/u01/app/oracle/fast_recovery_area/esbqas/ESBQAS/autobackup/2021_04_13/o1_mf_s_1069775467_j7bmcdjh_.bkp
  SPFILE Included: Modification time: 13-APR-21
  SPFILE db_unique_name: ESBQAS
  Control File Included: Ckp SCN: 417116004    Ckp time: 13-APR-21
#删除备份,指定备份片序号删除 ,多个可以用逗号分隔
RMAN>  delete backupset 2;

using channel ORA_DISK_1
List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
2       2       1   1   AVAILABLE   DISK        /oracle/backup/ESB_ful_03vs6uad_1_1

Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/oracle/backup/ESB_ful_03vs6uad_1_1 RECID=2 STAMP=1069775183
Deleted 1 objects

参考

登陆评论: 使用GITHUB登陆