RMAN命令DELETE操做總結

本篇總結一下RMAN命令中的DELETE操做,DELETE命令用於刪除RMAN備份記錄以及相應的物理文件。c#

 

To delete physical backups and copies as well as do the following:oracle

1 Update their repository records in the target control file to status DELETEDapp

2 Remove their repository records from the recovery catalog (if you use a catalog)ide

 

When running RMAN interactively, DELETE displays a list of the files and promptsthis

you for confirmation before deleting any file in the list. When reading commands fromspa

a command file, RMAN will not prompt for confirmation.日誌

 

DELETE removes the physical files from the backup media, deletes the record ofcode

the backup from the recovery catalog (if RMAN is connected to a recovery catalog),orm

and updates the records of these backups in the control file to status DELETEDci

 

 

 

刪除歸檔日誌

 

 

 

刪除某個Sequence以前(包含該Sequence)的歸檔日誌

 

RMAN>delete archivelog until sequence xxx;

RMAN>delete archivelog from sequence xxx until  sequence xxx;

 

 

刪除系統時間1天之前的歸檔日誌,不會刪除閃回區有效的歸檔日誌(能夠指定刪除多久日誌)

 

RMAN>delete archivelog all completed before 'sysdate-1';

 

force參數表示會刪除有效歸檔日誌

 

RMAN>delete force archivelog all completed before 'sysdate-1';

 

 

刪除某個時間段的歸檔日誌,例如刪除20天前到2天前的歸檔日誌。

 

RMAN>delete archivelog from time 'sysdate-20' until time 'sysdate-2';

RMAN>delete archivelog from time 'sysdate-1';

 

注意:此命令會刪除閃回區的有效歸檔日誌。

 

 

刪除全部的歸檔日誌。

 

RMAN>delete noprompt archivelog all;   

RMAN>delete noprompt archivelog all completed before 'sysdate'; 

 

 

 

RMAN> delete expired archivelog all;

 

 

 

 注意delete expired archivelog all  實際上此命令不會真正刪除歸檔日誌,它刪除的是那些原本RMAN覺得存在可是實際上在磁盤或者磁帶上已經被刪除了文件的信息,實際刪除的只是RMAN資料庫或控制文件中的記錄;

 

 

RMAN> delete obsolete;

RMAN> delete noprompt obsolete;

 

 注意delete obsolete這個是清理過時備份,它也會刪除過時的歸檔日誌。可是特殊狀況下,除閃回區有效的歸檔日誌不會刪除。

 

 上面都是使用RMAN命令刪除歸檔日誌,最後一種方式,也是最不推薦的一種方式就是使用命令從系統系統刪除歸檔日誌,使用rm刪除了備份文件後,須要執行crosscheck archivelog all命令校檢歸檔日誌是否失效。

 

 

 

 

刪除備份

 

 

刪除過時備份

 

刪除過時備份,RMAN會根據備份冗餘策略肯定備份是否過時。而後刪除過時的備份。

 

RMAN> report obsolete;
RMAN> delete obsolete;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           1      18-MAY-17         
  Backup Piece       1      18-MAY-17           /u03/backup/backupsets/ora_df944345823_s1_s1
Control File Copy     1      18-MAY-17          /u03/backup/backupsets/controlfile.copy
 
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u03/backup/backupsets/ora_df944345823_s1_s1 recid=1 stamp=944345824
deleted control file copy
control file copy filename=/u03/backup/backupsets/controlfile.copy recid=1 stamp=944347366
Deleted 2 objects

 

刪除無效備份

 

  RMAN> delete expired backup;

 

關於delete obsolete 與delete expired backup的區別:

 

備份集有兩種狀態A(Available,RMAN認爲該項存在於備份介質上), X(Expired,備份存在於控制文件或恢復目錄中,可是並無物理存在於備份介質上),通常要運行CROSSCHECK才能檢查,關於delete expired與delete obsolete的區別

 

  delete obsolete 會刪除舊於備份保留策略定義的備份數據同時也更新RMAN資料庫以及控制文件。

  delete expired 刪除的是那些原本RMAN覺得存在可是實際上在磁盤或者磁帶上已經被刪除了的信息,刪除的只是RMAN資料庫中的記錄信息,也就是說delete expired是不會刪除備份集文件的。

 

 英文相關資料資料以下:

 

RMAN> delete obsolete;

Removes only files whose status in the repository is EXPIRED. RMAN marks backups and copies as expired when you run a CROSSCHECK command and the files are absent or inaccessible. To determine which files are expired, run a LIST EXPIRED command.

 

RMAN> delete obsolete;

 

Deletes data file backups and copies recorded in the RMAN repository that are obsolete, that is, no longer needed (see Example 2-66). RMAN also deletes obsolete archived redo log files and log backups.

RMAN determines which backups and copies of data files are no longer needed, which in turn determines when logs (and backups of logs) are no longer needed. RMAN considers the creation of a data file as a backup when deciding which logs to keep.

RMAN first uses the options specified with obsOperandList to determine which files are obsolete. If you do not specify options in obsOperandList, then RMAN uses the options specified in CONFIGURE RETENTION POLICY.

Note: DELETE OBSOLETE considers only the backup retention policy and does not use the configured archived log deletion policy to determine which logs are obsolete. In contrast, DELETE ARCHIVELOG ALL considers only the configured archived log deletion policy.

Note: If you make a backup with the KEEP UNTIL TIME clause, then this backup becomes obsolete after the specified KEEP time passes and is removed by DELETE OBSOLETE. RMAN does not consider the backup retention policy for archival backups whose KEEP time has expired.

 

 

刪除EXPIRED副本

 

 

RMAN> delete expired copy;

 

刪除特定印象副本

 

RMAN> delete datafile copy 'xxxxxxxxxxx';

 

刪除特定備份集

 

RMAN> delete backupset 24;
 
using channel ORA_DISK_1
 
List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
24      24      1   1   AVAILABLE   DISK        /u01/app/oracle/flash_recovery_area/GSP/backupset/kerryfull_GSP_20170520_25
 
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/GSP/backupset/kerryfull_GSP_20170520_25 RECID=24 STAMP=944472557
Deleted 1 objects

 

 

刪除特定備份片

 

RMAN> delete backuppiece '/u01/app/oracle/flash_recovery_area/GSP/backupset/kerryfull_GSP_20170520_26';
 
using channel ORA_DISK_1
 
List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
25      25      1   1   AVAILABLE   DISK        /u01/app/oracle/flash_recovery_area/GSP/backupset/kerryfull_GSP_20170520_26
 
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/GSP/backupset/kerryfull_GSP_20170520_26 RECID=25 STAMP=944472653
Deleted 1 objects

 

 

刪除全部備份集

 

RMAN> delete backup;

RMAN> delete noprompt backup;

 

 

刪除全部備份文件副本

 

 

RMAN> delete datafilecopy all;

 

 

刪除某個備份文件副本

 

RMAN> delete datafilecopy xxx;

相關文章
相關標籤/搜索