rman清除歸檔日誌經典資料
轉載於:清除歸檔日誌
1、清除歸檔日誌的方式
a、手動刪除
使用rm 或者find方式來刪除,透過該方式刪除之後,在RMAN下可以透過 crosscheck archivelog all 校驗歸檔是否失效,如下面的操作:
1 2 3 |
rm -rf arch_816906485_1_10.arc find /u02/database/GOBO1/archive/ -ctime +0 -delete RMAN> crosscheck archivelog all |
b、使用RMAN方式清除
RMAN清除方式會自動清除磁碟上的歸檔日誌檔案,同時會釋放控制檔案中對應的歸檔日誌的歸檔資訊。
可以基於不同的條件來清除歸檔日誌,如基於SCN,基於SEQUENCE,基於TIME等方式。
對於上述的三種方式又可以配合from, until, between .. and .. 等等子句來限定範圍,方式靈活多變。
下面的命令用於校驗歸檔日誌的有效性,列出無效的歸檔日誌,以及以何種方式清除歸檔日誌,列出幾種常用的:
1 2 3 4 5 6 7 8 |
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; --->同上一命令 |
2、演練使用RMAN清除歸檔日誌
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
[python] robin@SZDB:~> export ORACLE_SID=GOBO1 robin@SZDB:~> rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Jul 11 17:07:00 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: GOBO1 (DBID=733951103)
RMAN> host;
robin@SZDB:~> cd /u02/database/GOBO1/archive/ robin@SZDB:/u02/database/GOBO1/archive> ls arch_816906485_1_10.arc arch_816906485_1_12.arc arch_816906485_1_11.arc arch_816906485_1_13.arc ............
robin@SZDB:/u02/database/GOBO1/archive> rm -rf arch_816906485_1_10.arc arch_816906485_1_11.arc arch_816906485_1_12.arc robin@SZDB:/u02/database/GOBO1/archive> exit; exit host command complete
RMAN> crosscheck archivelog all; released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_9.arc recid=2085 stamp=817211151 validation failed for archived log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_10.arc recid=2086 stamp=817250793 .............. validation succeeded for archived log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_90.arc recid=2166 stamp=820458049 Crosschecked 83 objects
RMAN> list expired archivelog all;
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2086 1 10 X 20130604 11:05:51 /u02/database/GOBO1/archive/arch_816906485_1_10.arc 2087 1 11 X 20130604 22:06:17 /u02/database/GOBO1/archive/arch_816906485_1_11.arc 2088 1 12 X 20130605 19:30:53 /u02/database/GOBO1/archive/arch_816906485_1_12.arc
RMAN> delete archivelog until sequence 16;
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2084 1 8 A 20130604 09:53:17 /u02/database/GOBO1/archive/arch_816906485_1_8.arc ................. 2092 1 16 A 20130607 22:03:23 /u02/database/GOBO1/archive/arch_816906485_1_16.arc
Do you really want to delete the above objects (enter YES or NO)? yes ............... deleted archive log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_16.arc recid=2092 stamp=817516861 Deleted 9 objects
RMAN> delete archivelog all completed before 'sysdate-7';
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2093 1 17 A 20130608 00:01:00 /u02/database/GOBO1/archive/arch_816906485_1_17.arc 2094 1 18 A 20130608 18:00:17 /u02/database/GOBO1/archive/arch_816906485_1_18.arc ........... deleted archive log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_72.arc recid=2148 stamp=819847035 Deleted 56 objects
RMAN> list copy of database archivelog all;
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2149 1 73 A 20130703 23:17:13 /u02/database/GOBO1/archive/arch_816906485_1_73.arc 2150 1 74 A 20130704 22:00:19 /u02/database/GOBO1/archive/arch_816906485_1_74.arc 2151 1 75 A 20130704 22:04:40 /u02/database/GOBO1/archive/arch_816906485_1_75.arc ............... 2164 1 88 A 20130709 23:19:34 /u02/database/GOBO1/archive/arch_816906485_1_88.arc 2165 1 89 A 20130710 13:00:34 /u02/database/GOBO1/archive/arch_816906485_1_89.arc 2166 1 90 A 20130710 22:02:44 /u02/database/GOBO1/archive/arch_816906485_1_90.arc
RMAN> delete archivelog from time 'sysdate-1';
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2165 1 89 A 20130710 13:00:34 /u02/database/GOBO1/archive/arch_816906485_1_89.arc 2166 1 90 A 20130710 22:02:44 /u02/database/GOBO1/archive/arch_816906485_1_90.arc
Do you really want to delete the above objects (enter YES or NO)? yes deleted archive log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_89.arc recid=2165 stamp=820447373 deleted archive log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_90.arc recid=2166 stamp=820458049 Deleted 2 objects
RMAN> delete archivelog all completed before 'sysdate - 1';
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2149 1 73 A 20130703 23:17:13 /u02/database/GOBO1/archive/arch_816906485_1_73.arc ....................... 2164 1 88 A 20130709 23:19:34 /u02/database/GOBO1/archive/arch_816906485_1_88.arc
Do you really want to delete the above objects (enter YES or NO)? yes ................ archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_88.arc recid=2164 stamp=820414835 Deleted 16 objects
RMAN> sql " alter system archive log current";
sql statement: alter system archive log current
RMAN> list copy of archivelog all;
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2167 1 91 A 20130711 01:00:48 /u02/database/GOBO1/archive/arch_816906485_1_91.arc
RMAN> delete noprompt archivelog all completed before 'sysdate';
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=1075 devtype=DISK
List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - ----------------- ---- 2167 1 91 A 20130711 01:00:48 /u02/database/GOBO1/archive/arch_816906485_1_91.arc deleted archive log archive log filename=/u02/database/GOBO1/archive/arch_816906485_1_91.arc recid=2167 stamp=820517964 Deleted 1 objects |
3、清除歸檔日誌簡單的shell指令碼
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
[python] #對於RAC環境或者ASM需要清除archive,使用shell指令碼呼叫RMAN是比較妥當的方式 #其次,如果你的archive位於閃回區,制定合理的保留策略,也可以讓Oracle自動老化無用的歸檔日誌 robin@SZDB:~/dba_scripts/custom/bin> more clean_arch.sh # +-------------------------------------------------------+ # + Clean archived log as specified time | # + Author : Robinson | # + Blog : http://blog.csdn.net/robinson_0612 | # + Usage : | # + clean_arch.sh $ORACLE_SID | # +-------------------------------------------------------+ # #!/bin/bash # -------------------- # Define variable # --------------------
if [ -f ~/.bash_profile ]; then . ~/.bash_profile fi
if [ -z "${1}" ];then echo "Usage: " echo " `basename $0` ORACLE_SID" exit 1 fi
ORACLE_SID=$1; export ORACLE_SID
$ORACLE_HOME/bin/rman log=/users/robin/log/rman.log < connect target / run{ crosscheck archivelog all; delete noprompt expired archivelog all; delete noprompt archivelog all completed before 'sysdate - 1'; } exit;
EOF |
|
|
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29119536/viewspace-1136209/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle RMAN 清除歸檔日誌Oracle
- Oracle RMAN清除歸檔日誌Oracle
- 無歸檔日誌恢復rman資料
- 配置RMAN清除已應用到備庫的歸檔日誌
- rman清理歸檔日誌
- RMAN備份資料檔案+控制檔案+歸檔日誌
- rman維護歸檔日誌
- oracle 10g 歸檔日誌清除Oracle 10g
- ORACLE RMAN 還原歸檔日誌Oracle
- 作用RMAN 刪除歸檔日誌
- 用RMAN備份歸檔日誌時檢查歸檔日誌是否存在
- RMAN delete archivelog命令刪除歸檔日誌及歸檔日誌拷貝deleteHive
- RMAN備份歸檔日誌指令碼指令碼
- 配置RMAN清除已應用到備庫的歸檔日誌 (文件 ID 1577382.1)
- Oralce資料庫關閉歸檔日誌並且刪除歸檔日誌資料庫
- Linux/Unix shell 指令碼清除歸檔日誌檔案Linux指令碼
- rman 還原歸檔日誌(restore archivelogRESTHive
- RMAN備份歸檔日誌多份 %c
- rman 還原歸檔日誌(restore archivelog)RESTHive
- rman刪除歸檔日誌命令集
- Oracle RAC中使用RMAN管理歸檔日誌Oracle
- 【Oracle】 rman 刪除歸檔日誌的命令Oracle
- oracle rman備份歸檔日誌需要先切換日誌嗎Oracle
- 用rman 正確地刪除歸檔日誌
- 11.2.0.3.2 RMAN無法恢復歸檔日誌
- rman刪除舊的歸檔日誌問題
- 資料檔案重建,從歸檔日誌中回退資料
- rman全庫備份備份歸檔日誌檔案
- 歸檔日誌
- 【Oracle】歸檔日誌管理-設定歸檔日誌路徑以及歸檔日誌冗餘Oracle
- 歸檔日誌無法歸檔導致資料庫hang住資料庫
- RAC環境備份歸檔日誌和RMAN恢復啟動資料庫資料庫
- 清除閃回資料歸檔區資料
- 清除SQL Server資料庫日誌SQLServer資料庫
- 11gR2 RMAN歸檔日誌刪除策略
- RMAN備份整庫和歸檔日誌的方法
- rman 刪除指定時間點的歸檔日誌
- oracle資料庫歸檔日誌量陡增分析Oracle資料庫