本篇總結一下RMAN命令中的DELETE操作,DELETE命令用於刪除RMAN備份記錄以及相應的物理文件。 To delete physical backups and copies as well as do the following: 1: Update their repository re... ...
本篇總結一下RMAN命令中的DELETE操作,DELETE命令用於刪除RMAN備份記錄以及相應的物理文件。
To delete physical backups and copies as well as do the following:
1: Update their repository records in the target control file to status DELETED
2: Remove their repository records from the recovery catalog (if you use a catalog)
When running RMAN interactively, DELETE displays a list of the files and prompts
you for confirmation before deleting any file in the list. When reading commands from
a command file, RMAN will not prompt for confirmation.
DELETE removes the physical files from the backup media, deletes the record of
the backup from the recovery catalog (if RMAN is connected to a recovery catalog),
and updates the records of these backups in the control file to status DELETED
刪除歸檔日誌
刪除某個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.