RAC資料庫大量載入資料造成歸檔日誌空間滿處理

湖湘文化發表於2013-12-22
 

RAC資料庫大量載入資料造成歸檔日誌空間滿處理

20130409,下午,將近4點領導接到客戶電話,資料庫報ORA-00257錯誤,資料庫歸檔空間滿了;安排我叫車前往客戶現場。

這是一個資料倉儲型別的RAC資料庫,版本10.2.0.4.0,系統為紅旗linux 5.5,使用ASM儲存

現象:

檢視資料庫告警日誌報錯不能歸檔,歸檔程式停止;

export ORACLE_SID=+ASM2

asmcmd

ASMCMD>lsdg

ASM 存放歸檔日誌的DG_ARCHIVE空間快滿了,1T多空間只剩不到50M;

檢查:

檢視最近tsm備份日誌,沒有發現問題,正常備份都成功了。

備份策略為半個月一次全備,其餘增量備份,每週刪除一次過期備份;

備份指令碼如下:

0級備份指令碼和1級備份指令碼都包含:

backup format 'arch_%t_%s_%p.arc' archivelog all delete input;

交叉檢驗刪除過期廢棄的備份集指令碼:

RMAN> allocate channel for maintenance device type sbt parms 'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';

2> crosscheck archivelog all;

3> crosscheck backup;

4> delete noprompt obsolete;

5> delete noprompt expired backup;

6> release channel;

分析原因:

之前也出現過歸檔空間滿的情況,是因為虛擬帶庫空間滿導致TSM備份出錯從而沒有及時將歸檔日誌備份成功並清除掉;

這次是最近一週第三方維護公司人員大量往資料庫里載入資料,造成歸檔空間迅速被佔滿,還沒來得及清理空間資料庫就不可用了;

處理方法:

第一種情況

因為虛擬帶庫空間滿,所以計劃先備份沒有刪除的歸檔日誌到本地空間,然後刪除釋放空間,資料庫恢復可用,前提是本地有足夠大的空間:

rman target /    

backup as compressed backupset archivelog format ‘/arch/%t_%s_%p.arc’;

歸檔日誌量大,備份很費時間;如果著急恢復可用,可先直接刪除部分歸檔日誌使資料庫迅速可用,然後考慮對資料庫做一個全備份。

第二種情況

常規處理方法,先備份最近部分或全部歸檔日誌然後刪除,釋放空間資料庫恢復可用

如備份53日的歸檔然後刪除

backup archivelog time between 'sysdate-7' and 'sysdate-6' delete all input;

客戶著急恢復資料庫可用,資料載入只進行到一半,後續還有很多資料需要載入。

asm裡,找到相應的歸檔日誌,直接rm –r刪除掉了幾個以日期命名的歸檔日誌目錄

臨時刪除掉3-7日的歸檔日誌,釋放近1T空間,更改定時任務,晚上做一次全備份

export ORACLE_SID=+ASM2;

asmcmd

ASMCMD>lsdg

ASMCMD>cd dg_archive

ASMCMD>cd standby/archivelog/

ASMCMD>du -H *

ASMCMD>rm -r 2013-05-03/*

交叉檢驗相關資訊

rman target / nocatelog;

crosscheck archivelog all;

list expired archivelog all;

delete expired archivelog all;

crosscheck archivelog all;

後續思考:

問題一:

將某一天或某些天的歸檔日誌備份到本地然後刪除釋放空間?

可以根據日誌序號或者日期還有匹配關係來選擇備份

BACKUP ARCHIVELOG LIKE '...',

delete archivelog until time 'sysdate-7'

DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';

語法:

backup archivelog "all, from, high, like, logseq, low, scn, sequence, time, until"

備份所有的歸檔日誌:

backup archivelog all;

backup archivelog all delete input;backup archivelog delete all input;

備份日誌序號31以後的所有歸檔日誌:

backup archivelog from logseq 31;   logseq, scn, sequence, time

備份日誌序號為3132的兩個歸檔日誌:

backup archivelog sequence between 31 and 32;

備份最近3天的歸檔日誌

backup archivelog time between 'sysdate-3' and 'sysdate';

backup archivelog from time 'sysdate-3';

根據歸檔日誌命名規範匹配備份:

backup archivelog like '%3%';

問題二:

資料倉儲可考慮不啟用歸檔模式?


archivelog all delete inputdelete all input的區別:

rmanbackup archivelog all delete inputdelete all input,還是有區別的,如果你有多個archive_dest的設定,1,2,3,4,5。後者帶著all的,能夠刪除掉所有歸檔位置的歸檔日誌,而前者不帶all的,可能無法刪除所有節點的。

4.3.7.1.2 Using BACKUP ARCHIVELOG with DELETE INPUT or DELETE ALL INPUT
You can specify the DELETE INPUT or DELETE ALL INPUT clauses for the BACKUP ARCHIVELOG command to delete archived logs after they are backed up, eliminating the separate step of manually deleting the archived redo logs. With DELETE INPUT, RMAN only deletes the specific copy of the archived redo log chosen for the backup set. With DELETE ALL INPUT, RMAN will delete each backed-up archived redo log file from all log archiving destinations.
For example, assume that you archive to /arc_dest1, /arc_dest2, and /arc_dest3, and you run the following command:
BACKUP DEVICE TYPE sbt
ARCHIVELOG ALL
DELETE ALL INPUT;


In this case RMAN backs up only one copy of each log sequence number in these directories, and then deletes all copies of any log that it backed up from the archiving destinations. If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would only delete the specific archived redo log files that it backed up (for example, it would delete the archived redo log files in /arc_dest1 if those were the files used as the source of the backup, but it would leave the contents of the /arc_dest2 and /arc_dest3 intact) .
If you issue BACKUP ARCHIVELOG ALL or BACKUP ARCHIVELOG LIKE '...', and there are no archived redo log files to back up, then RMAN does not signal an error.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21256317/viewspace-1063982/,如需轉載,請註明出處,否則將追究法律責任。

相關文章