Oracle下定時刪除歸檔日誌指令碼

來源:互聯網
上載者:User

標籤:oracle   歸檔日誌   指令碼   

一、報錯資訊

前幾天網站突然訪問不了,並且報了如下錯誤:

ora-27101: shared memory realm does not exist

ora-01034: oracle not available 11g

ORA-24324: service handle not initialized


原因:由於資料庫歸檔日誌滿了,不能繼續往資料庫裡寫資料。


二、查看歸檔日誌大小

su - oracle

sqlplus / as sysdba

show parameter recover


可查看到歸檔日誌目錄為:/u01/app/oracle/fast_recovery_area/******/archivelog

可以查看該目錄的大小,對比資料庫設定的日誌空間,該目錄大小不能大於資料庫設定的空間。


三、擴大歸檔日誌大小

alter system set db_recovery_file_dest_size=100G;


四、清理歸檔日誌

擴大後還需設定定時計劃清理歸檔日誌,需要切換到oracle帳號執行命令

rman target /

RMAN> crosscheck archivelog all;

RMAN> delete expired archivelog all;

RMAN> delete archivelog until time 'sysdate-3'

 

上面三條命令的解釋:

1、第一條命令可以把無效的expired的archivelog標出來。

2、第二條命令直接全部刪除到期的歸檔日誌。

3、第三條命令直接刪除三天前所有的歸檔日誌。

參考:https://www.2cto.com/database/201308/235338.html


五、設定自動指令碼

1、編寫指令碼

su - oracle        //切換到oracle使用者下執行操作

cd /u01/app

vim arcclear.sh

#!/usr/binrman target / <<EOFdelete force noprompt archivelog all completed before 'sysdate-3';exit;EOF

chmod +x arcclear.sh


2、添加到計劃任務

crontab -e

30 1 * * * sh /u01/app/arcclear.sh >> /u01/app/arcclear.log

service crond restart








Oracle下定時刪除歸檔日誌指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.