模擬control file及redo log故障


實驗1:Control File 故障
===============================================================

1.環境模擬

select * from v$controlfile;

利用O.S.的指令修改Control file的內容

select * from v$datafile;

發現Control file Error

ERROR at line 1:
ORA-00227: corrupt block detected in controlfile: (block 1, # blocks 1)
ORA-00202: controlfile: '/oradata/sent/ctl/control01.ctl'


shutdown immediate;
失敗


shutdown abort;

將其他好的control file複製到原來的位置上

startup
================================================================================






實驗2:offline Redo Log File 故障(內容錯誤)
===============================================================

select * from v$log;

select * from v$logfile;

利用O.S.指令來修改redo log file的內容


SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel

或者

alter system switch logfile;
*
ERROR at line 1:
ORA-01034: ORACLE not available


select * from v$log
*
ERROR at line 1:
ORA-01034: ORACLE not available


SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  319886536 bytes
Fixed Size                   451784 bytes
Variable Size             150994944 bytes
Database Buffers          167772160 bytes
Redo Buffers                 667648 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/oradata/sent/redo/redo01.log'

shutdown abort;

因為每個群組只有一個Redo Log File,假設有兩個,資料庫運作不會有問題,
只要把好的複製到壞的就可以了。


方法一:清空內容
alter database clear logfile '/oradata/sent/redo/redo01.log';

alter database open;


方法二:
shutdown abort;
startup mount;
alter database drop logfile group 1;
利用O.S.刪除group 1 的檔案
alter database add logfile group 1  ('/oradata/sent/redo/redo01.log') size 50M;
alter database open;