Oracle日誌檔案常用操作

weixin_34126215發表於2015-03-31

Oracle關於日誌檔案基本操作
1.查詢系統使用的是哪一組日誌檔案:
select * from v$log;

2.查詢正在使用的組所對應的日誌檔案:
select * from v$logfile;

3.強制日誌切換:
alter system switch logfile;

4.查詢歷史日誌:
select * from v$log_history;

5.查詢日誌的歸檔模式:
select dbid,name,created,log_mode from v$database;

6.查詢歸檔日誌的資訊:
select recid,stamp,thread#,sequence#,name from v$archived_log;

7.增加與刪除日誌檔案組
alter database add logfile group 1 ('/home1/Oracle/oradata/ora8i/log1a.log'),'/home2/oracle/oradata/ora8i/log1b.log') size 100M;

alter database drop logfile group 1;

8.增加與刪除日誌成員
alter database add logfile member '/home1/oracle/oradata/ora8i/log1a.log' to group 1,'/home1/oracle/oradata/ora8i/log2a.log' to group 2;

alter database drop logfile member '/home1/oracle/oradata/ora8i/log1a.log' ;

9.日誌檔案移動
alter database rename file '/home1/oracle/oradata/ora8i/log1a.log' to '/home2/oracle/oradata/ora8i/log1a.log';
執行該命令之前必須保證該日誌檔案物理上已經移動到新目錄

10.清除日誌檔案
alter database clear logfile '/home1/oracle/oradata/ora8i/log1a.log';
該命令用於不能用刪除組及組成員命令刪除日誌時使用

8.檢視歸檔日誌佔用空間:
SELECT space_limit/1024/1024/1024 AS "Quota_G",space_used/1024/1024 AS "Used_M",space_used/space_limit*100 "Used_%",space_reclaimable AS reclaimable,number_of_files AS files FROM v$recovery_file_dest ;

9.修改歸檔日誌空間大小
alter system set DB_RECOVERY_FILE_DEST_SIZE=40g;

10.檢視歸檔日誌列表
RMAN> list archivelog all;
刪除歸檔日誌
RMAN> delete archivelog until time 'sysdate-1' ;
雙機下也可以用
delete obsolete;
crosscheck archivelog all;
delete expired archivelog all;

11. 用list expired看看是否有失效的archive log,證明沒有失效的archive log:
RMAN> list expired archivelog all;

相關文章