對於Oracle Data Guard 的Maximum Availability和 Maximum Performance 兩種模式下的主庫歸檔檔案的刪除,必須是在歸檔檔案在備庫應用以後才可以刪除。
對於Maximum Protection 模式,這種模式的日誌是同時寫到主庫和備庫的,所以這種模式下的主庫刪除歸檔,沒有限制。 可以直接刪除。
那麼在Maximum Availability和 Maximum Performance下,RMAN 備份歸檔檔案的時候,如果我們加上delete input,那麼如何確定歸檔問及愛你該不該刪除。
在10g之前的版本,只能通過作業系統指令碼的方式,在刪除歸檔檔案之前,首先對Standby端資料庫的歸檔檔案應用狀態作判斷,應用之後才能在Primary端執行正常刪除。
在Oracle 10g 後,RMAN提供了配置歸檔檔案刪除策略: configure archivelog deletion policy
該策略對應兩個值:
APPLIED ON STANDBY :設定為該值時,當通過附加的 DELETE INPUT 子句刪除Standby資料庫仍需要的日誌時,會提示RMAN-08137錯誤。不過仍然可以手動地通過 DELETE ARCHIVELOG 方式刪除。
NONE :設定為該值時,則不啟用歸檔檔案的刪除策略。預設情況下就是NONE。
我們配置一下:
RMAN> configure archivelog deletion policy to applied on standby;
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters are successfully stored
RMAN-08591: WARNING: invalid archivelog deletion policy
這裡有個警告, 解決方案,執行如下命令:
SQL>alter system set "_log_deletion_policy"=ALL scope=spfile sid='*';
設定該參數以後,DB 需要重啟。
修改之後,我們在設定:
RMAN> configure archivelog deletion policy to applied on standby;
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters are successfully stored
RMAN> configure archivelog deletion policy to none;
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
new RMAN configuration parameters are successfully stored
修改之後成功修改RMAN 的歸檔檔案刪除策略。