您好,登錄后才能下訂單哦!
我們都都知道在controlfile中記錄著每一個(gè)archivelog的相關(guān)信息,當(dāng)然們?cè)贠S下把這些物理文件delete掉后,在我們的
controlfile中仍然記錄著這些archivelog的信息,在oracle的OEM管理器中有可視化的日志展現(xiàn)出,當(dāng)我們手工清除archive目錄下的文件后,這些記錄并沒(méi)有被我們從controlfile中清除掉,也就是oracle并不知道這些文件已經(jīng)不存在了!這時(shí)候我們要做手工的清除的話,下面我經(jīng)過(guò)實(shí)驗(yàn),可以嘗試這種方法:
1. 進(jìn)入rman
2. connect target /
3. crosscheck archivelog all;
4. delete expired archivelog all;
這時(shí)候我們?cè)偃EM中看就一定看不到,如果你的從來(lái)沒(méi)有做過(guò)這個(gè)動(dòng)作的話,我們可以比較從這個(gè)動(dòng)作前的controlfile后動(dòng)作后的controlfile的大小!
ORACLE正確刪除歸檔并回收空間的方法
ORACLE正確刪除歸檔并回收空間的方法
一個(gè)ORACLE歸檔日志經(jīng)常滿,表現(xiàn)為/oraarchive 這個(gè)文件空間占用100%大家一定抱怨ORACLE為何沒(méi)有歸檔維護(hù)工具,很多人直接刪除了事,錯(cuò)了,ORACLE有,而且很智能,可以正確的刪除歸檔和FLASHBACK,不過(guò)切記,ORACLE歸檔日志對(duì)于ORACLE的數(shù)據(jù)恢復(fù)和備份非常重要,不到萬(wàn)不得已不要?jiǎng)h除歸檔日志。
刪除歸檔日志的過(guò)程
以O(shè)RACLE用戶身份登錄到數(shù)據(jù)庫(kù)服務(wù)器主機(jī)或通過(guò)網(wǎng)絡(luò)連接
進(jìn)入ORACLE數(shù)據(jù)備份工具
rman target/
或rman target/@orcl
在命令窗口里面執(zhí)行
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';
說(shuō)明
SYSDATA-7,表明當(dāng)前的系統(tǒng)時(shí)間7天前,before關(guān)鍵字表示在7天前的歸檔日志,如果使用了閃回功能,也會(huì)刪除閃回的數(shù)據(jù)。
同樣道理,也可以刪除從7天前到現(xiàn)在的全部日志,不過(guò)這個(gè)命令要考慮清楚,做完這個(gè)刪除,最好馬上進(jìn)行全備份數(shù)據(jù)庫(kù)
DELETE ARCHIVELOG FROM TIME 'SYSDATE-7';
UNIX/LINUX下也可以通過(guò)FIND找到7天前的歸檔數(shù)據(jù),使用EXEC子操作刪除
find /oraarchive -xdev -mtime +7 -name "*.dbf" -exec rm -f {} ;
這樣做仍然會(huì)在RMAN里留下未管理的歸檔文件
仍需要在RMAN里執(zhí)行下面2條命令
crosscheck archivelog all;
delete expired archivelog all;
所以還不如上面的方法好用,不過(guò)用FIND的好處就是,可以在條件上,和EXEC子項(xiàng)上做很多操作,實(shí)現(xiàn)更復(fù)雜的功能
3.簡(jiǎn)要介紹一下report obsolete命令
使用report obsolete命令報(bào)告過(guò)期備份
RMAN> report obsolete;RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1Report of obsolete backups and copiesType Key Completion Time Filename/Handle-------------------- ------ ------------------ --------------------Backup Set 125 01-NOV-04Backup Piece 125 01-NOV-04 /data1/oracle/orabak/full_1_541045804Backup Set 131 04-NOV-04Backup Piece 131 04-NOV-04 /data1/oracle/orabak/full_AVATAR2_20041104_131....Backup Set 173 06-DEC-04Backup Piece 173 06-DEC-04 /data1/oracle/orabak/full_AVATAR2_20041206_173Backup Set 179 11-DEC-04Backup Piece 179 11-DEC-04 /data1/oracle/orabak/arch644588206.arc.....Backup Piece 189 17-DEC-04 /data1/oracle/orabak/arch645106606.arcBackup Set 190 17-DEC-04Backup Piece 190 17-DEC-04 /data1/oracle/orabak/arch645106665.arcBackup Set 191 20-DEC-04Backup Piece 191 20-DEC-04 /data1/oracle/orabak/arch_AVATAR2_20041220_194Archive Log 2973 20-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2985.dbfArchive Log 2971 20-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2984.dbf.....Archive Log 2705 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2717.dbfArchive Log 2704 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2716.dbfArchive Log 2703 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2715.dbfArchive Log 2702 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2714.dbf
4.使用delete obsolete命令刪除過(guò)期備份:
RMAN> delete obsolete;RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1using channel ORA_DISK_1Deleting the following obsolete backups and copies:Type Key Completion Time Filename/Handle-------------------- ------ ------------------ --------------------Backup Set 125 01-NOV-04Backup Piece 125 01-NOV-04 /data1/oracle/orabak/full_1_541045804....Archive Log 2704 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2716.dbfArchive Log 2703 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2715.dbfArchive Log 2702 17-DEC-04 /opt/oracle/oradata/avatar2/archive/1_2714.dbfDo you really want to delete the above objects (enter YES or NO)? yesdeleted backup piecebackup piece handle=/data1/oracle/orabak/full_AVATAR2_20041206_173 recid=173 stamp=544156241.....deleted archive logarchive log filename=/opt/oracle/oradata/avatar2/archive/1_2715.dbf recid=2703 stamp=545108268deleted archive logarchive log filename=/opt/oracle/oradata/avatar2/archive/1_2714.dbf recid=2702 stamp=545107659Deleted 286 objectsRMAN> crosscheck archivelog all;released channel: ORA_DISK_1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=19 devtype=DISKspecification does not match any archive log in the recovery catalog
5 在rman中用crosscheck檢查歸檔日志,2個(gè)歸檔日志都是失敗的:
RMAN> crosscheck archivelog all;
釋放的通道: ORA_DISK_1
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=14 devtype=DISK
對(duì)歸檔日志的驗(yàn)證失敗
存檔日志文件名 =D:ORACLEORADATATESTARCHIVE1_47.DBF 記錄 ID=1 時(shí)間戳 =572866
683
對(duì)歸檔日志的驗(yàn)證失敗
存檔日志文件名 =D:ORACLEORADATATESTARCHIVE11_48.DBF 記錄 ID=2 時(shí)間戳 =57286
6931
已交叉檢驗(yàn)的 2 對(duì)象
6 試著同步一下,看行不行,結(jié)果不行,crosscheck還是失敗:
RMAN> resync catalog;
正在啟動(dòng)全部恢復(fù)目錄的 resync
完成全部 resync
RMAN> crosscheck archivelog all;
釋放的通道: ORA_DISK_1
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=14 devtype=DISK
對(duì)歸檔日志的驗(yàn)證失敗
存檔日志文件名 =D:ORACLEORADATATESTARCHIVE1_47.DBF 記錄 ID=1 時(shí)間戳 =572866
683
對(duì)歸檔日志的驗(yàn)證失敗
存檔日志文件名 =D:ORACLEORADATATESTARCHIVE11_48.DBF 記錄 ID=2 時(shí)間戳 =57286
6931
已交叉檢驗(yàn)的 2 對(duì)象
7 用list expired看看是否有失效的archive log,證明沒(méi)有失效的archive log:
RMAN> list expired archivelog all;
說(shuō)明與恢復(fù)目錄中的任何存檔日志均不匹配
8 更改語(yǔ)言環(huán)境試試,結(jié)果再次crosscheck,2個(gè)archive log 都成功了:
RMAN> exit
恢復(fù)管理器完成。
C:>set nls_lang=american_america.zhs16gbk
C:>rman catalogrman/rman@safetarget /
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: TEST (DBID=1870953724)
connected to recovery catalog database
RMAN> crosscheck archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=9 devtype=DISK
validation succeeded for archived log
archive log filename=D:ORACLEORADATATESTARCHIVE1_47.DBF recid=1 stamp=57286
6683
validation succeeded for archived log
archive log filename=D:ORACLEORADATATESTARCHIVE11_48.DBF recid=2 stamp=5728
66931
Crosschecked 2 objects
--
--------------------------------------------------------------------------------------
真實(shí)的生產(chǎn)環(huán)境 刪除歸檔日志
rman target/
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';
保留最近一天的歸檔日志
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。